小编Gan*_*aju的帖子

如何在spring-boot中添加多个application.properties文件?

我有一个Spring启动应用程序,它分为几个模块.主模块运行应用程序,并application.properties在resources文件夹中有一个文件.我想知道我是否可以在子模块中添加另一个属性文件来分隔属于该模块的属性以及如何使其工作(因为它不是).

+main_module
  +src
    +main
      +java
        +my/package/Application.java
        +resources/application.properties
+support_module
  +src
    +main
      +java
        +resources/application.properties
Run Code Online (Sandbox Code Playgroud)

所以,这就是目前的情况.显然,模块中的属性文件support_module不会被读取NoSuchBeanDefinitionException,而如果我将内容放在其他属性文件中,一切正常.

java spring spring-boot

29
推荐指数
4
解决办法
3万
查看次数

如何将请求有效负载发送到Java中的REST API?

我想从以下内容中检索JSON数据:https: //git.eclipse.org/r/#/c/11376/

请求网址: https://git.eclipse.org/r/gerrit/rpc/ChangeDetailService

请求方法: POST

请求标题:

Accept:application/json

Content-Type:application/json; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)

请求有效负载:

{"jsonrpc":"2.0","method":"changeDetail","params":[{"id":11376}],"id":1}
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这个答案,但我得到了400 BAD REQUEST.

任何人都可以帮我解决这个问题吗?

谢谢.

java rest httpurlconnection http-status-code-400

26
推荐指数
1
解决办法
11万
查看次数

如何在Gerrit中创建新的Patchset?

我是Gerrit的新手,想要在提交新的更改时创建一个新的Patch.我使用本指南https://review.typo3.org/Documentation/install-quick.html设置了Gerrit

然后我尝试使用http://gerrit.googlecode.com/svn/documentation/2.0/user-changeid.html创建一个新的补丁,并Change-Id在Commit-message的底部添加了一行.

但我正在获得新的改变,而不是新的Patchset.谁能帮我?

谢谢

git git-amend gerrit git-commit

14
推荐指数
1
解决办法
3万
查看次数

mysql_upgrade失败 - innodb表不存在?

我正在将我的mysql-5.5 docker容器数据库升级到mysql-5.6 docker容器.我能够解决所有其他问题.最后我的服务器运行5.6.但是当我运行mysql_upgrade时,我收到以下错误.

错误:

root@17aa74cbc5e2# mysql_upgrade -uroot -password           
Warning: Using a password on the command line interface can be insecure.
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock' 
Warning: Using a password on the command line interface can be insecure.
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysqld/mysqld.sock' 
Warning: Using a password on the command line interface can be insecure.
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.help_category                                OK …
Run Code Online (Sandbox Code Playgroud)

mysql innodb docker mysqlupgrade

14
推荐指数
2
解决办法
3万
查看次数

如何在docker容器中迁移mysql数据目录?

我有一个运行带有主机数据量的mysql-5.5的docker容器.我正在将我的容器升级到mysql-5.6.我正在启动一个具有相同主机卷的新容器.由于mysql.user表崩溃,MySQL在容器中崩溃.

[ERROR] Fatal error: Can't open and lock privilege tables: 
Incorrect key file for table 'user'; try to repair it
160523 12:04:13 mysqld_safe mysqld from pid file  /var/run/mysqld/mysqld.pid ended
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法来解决这个问题:

root@container# mysqld --skip-grant-tables;
root@container# mysql -uroot -ppassword
mysql> repair table user USE_FRM;
+------------+--------+----------+--------------------------------------------------+
| Table      | Op     | Msg_type | Msg_text                                         |
+------------+--------+----------+--------------------------------------------------+
| mysql.user | repair | info     | Key 1 - Found wrong stored record at 0           |
| mysql.user | repair | info     | Found …
Run Code Online (Sandbox Code Playgroud)

mysql data-migration database-migration docker mysql-5.6

12
推荐指数
2
解决办法
4610
查看次数

Terraform:创建IAM角色时出错.MalformedPolicyDocument:已禁止字段资源

我的TF代码给了我一个错误:

  /*
   * Policy: AmazonEC2ReadOnlyAccess
   */
  assume_role_policy = <<EOF
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "ec2:Describe*",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "elasticloadbalancing:Describe*",
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "cloudwatch:ListMetrics",
                "cloudwatch:GetMetricStatistics",
                "cloudwatch:Describe*"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": "autoscaling:Describe*",
            "Resource": "*"
        }
    ]
}
EOF
Run Code Online (Sandbox Code Playgroud)

我从https://console.aws.amazon.com/iam/home?region=us-west-2#/policies/arn:aws:iam::aws:policy/AmazonEC2ReadOnlyAccess $ jsonEditor 复制并粘贴了该政策.

* aws_iam_role.<role name>: Error creating IAM Role <role name>: MalformedPolicyDocument: Has prohibited field Resource
status code: 400, request id: <request id>
Run Code Online (Sandbox Code Playgroud)

不知道为什么说资源被禁止.

amazon-web-services amazon-iam terraform

11
推荐指数
1
解决办法
1万
查看次数

来自本地文件的MD5和来自S3的MD5(eTag)不一样

我获得了本地文件的MD5,但它与Amazon S3中"相同"文件的MD5(eTag)不同.我想要实现的是弄清楚我在S3中的最新文件是否与我本地的文件相同.如果我无法比较MD5,那我该怎么做呢?

从本地文件生成MD5(截断代码):

MessageDigest md = MessageDigest.getInstance("MD5");
byte[] md5 = Files.getDigest(localFile, md);
String hashtext = DigestUtils.md5Hex(md5);
Run Code Online (Sandbox Code Playgroud)

从S3(截断代码)中检索MD5(eTag):

ObjectListing objectListing = s3.listObjects(new ListObjectsRequest().withBucketName(bucketName));
List<S3ObjectSummary> objectSummaries = objectListing.getObjectSummaries();
for(S3ObjectSummary objectSummary : objectSummaries) {
    String MD5 = objectSummary.getETag();
}
Run Code Online (Sandbox Code Playgroud)

PS:我使用org.apache.commons.codec.digest.DigestUtilscom.google.common.io.Files库.

java md5 amazon-s3 md5sum

8
推荐指数
1
解决办法
9398
查看次数

从maven在nexus中部署工件会出现错误"返回代码是:401"?

我在nexus中部署时遇到401错误.我没有对已安装的nexus进行任何更改.Nexus正在运行localhost:8080/nexus,我可以使用默认用户/密码登录.当我正在运行mvn deploy时,我收到此错误.

这是我的POM.

 <groupId>testproject</groupId>
 <artifactId>testproject</artifactId>
 <packaging>jar</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>testproject</name>
 <url>http://maven.apache.org</url>
 <distributionManagement>
  <repository>
      <id>releases</id>
      <url>http://localhost:8080/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
       <id>snapshots</id>
       <url>http://localhost:8080/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>
<dependencies>
 .........
</dependencies>
Run Code Online (Sandbox Code Playgroud)

和〜/ .m2/settings.xml

<servers>
    <server>
        <id>snapshots</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
    <server>
        <id>releases</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
</servers>
Run Code Online (Sandbox Code Playgroud)

例外:

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-           deploy) on project testproject: Failed to deploy artifacts: Could not transfer artifact testproject:testproject:jar:1.0-20131213.150615-1 from/to snapshots (http://localhost:8080/nexus/content/repositories/snapshots): Failed to transfer file: http://localhost:8080/nexus/content/repositories/snapshots/testproject/testproject/1.0-SNAPSHOT/testproject-1.0-20131213.150615-1.jar. 
Return code is: 401 -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

请帮我.

nexus maven

8
推荐指数
1
解决办法
4万
查看次数

如何在intellij中为maven命令行项目添加程序参数?

我是intellij的新手.我想为我的maven命令行应用程序添加程序参数,以便它们可以在main(String[] args)方法中使用,例如:-pg 541,它指定了一些在我的main函数中触发的方法.

我试图通过直接在命令行部分添加参数使用Maven配置(运行/调试配置)来完成它,但它没有成功.

我还尝试了运行Maven项目的JUnit,但是程序参数部分被禁用了.

这是我尝试过的快照.

使用junit配置:

使用junit配置

使用maven配置:

使用maven配置

java intellij-idea maven intellij-14

7
推荐指数
1
解决办法
3699
查看次数

如何使用 terraform 在 API Gateway 中创建启用了 cloudwatch 指标的阶段?

我想在启用了 cloudwatch 指标的阶段部署它。为此,我需要使用aws_api_gateway_method_settingswhich need stage name。如果不使用aws_api_gateway_stage它创建阶段,则会抛出错误,指出阶段不存在。当我尝试创建一个阶段时,它所说的阶段已经存在。

我尝试的一种解决方案是创建两个阶段,一个使用两个不同的名称aws_api_gateway_deployment,另一个使用aws_api_gateway_stage两个不同的名称。对此还有其他解决方案吗?

resource "aws_api_gateway_deployment" "test-deploy" {
  depends_on = [ /*something goes here*/]

  rest_api_id = "${aws_api_gateway_rest_api.test.id}"
  stage_name  = "${var.stage_name}"

  variables = {
    "function" = "${var.lambda_function_name}"
  }
}

resource "aws_api_gateway_stage" "test" {
  stage_name = "${var.stage_name}"
  rest_api_id = "${aws_api_gateway_rest_api.test.id}"
  deployment_id = "${aws_api_gateway_deployment.test-deploy.id}"
}

resource "aws_api_gateway_method_settings" "settings" {
  rest_api_id = "${aws_api_gateway_rest_api.test.id}"
  stage_name  = "${aws_api_gateway_stage.test.stage_name}"
  method_path = "*/*"

  settings {
    metrics_enabled = true
    logging_level = "INFO"
  }
}
Run Code Online (Sandbox Code Playgroud)

例外:

aws_api_gateway_stage.test: Error creating …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-cloudwatch terraform aws-api-gateway

6
推荐指数
1
解决办法
4230
查看次数