Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven YAML解决Spring引导应用程序中的错误_Java_Maven_Spring Boot_Jhipster - Fatal编程技术网

Java Maven YAML解决Spring引导应用程序中的错误

Java Maven YAML解决Spring引导应用程序中的错误,java,maven,spring-boot,jhipster,Java,Maven,Spring Boot,Jhipster,我有一个SpringBoot(Jhipster生成的)项目。当我使用/mvnw运行我的项目时,它运行得很好,但当我尝试mvn包或mvn干净安装时,它崩溃了: Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'application.hotspot.path.audio' in value "${application.hotspot.path.audio}" 完整控制台日志: ▶ mvn p

我有一个SpringBoot(Jhipster生成的)项目。当我使用
/mvnw
运行我的项目时,它运行得很好,但当我尝试
mvn包
mvn干净安装时,它崩溃了:

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'application.hotspot.path.audio' in value "${application.hotspot.path.audio}" 完整控制台日志:

▶ mvn package
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building Arch 3 D 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:copy-resources (default-resources) @ arch-3-d ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 62 resources
[INFO] Copying 12 resources
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ arch-3-d ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 62 resources
[INFO] Copying 12 resources
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-versions) @ arch-3-d ---
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.9:prepare-agent (pre-unit-tests) @ arch-3-d ---
[INFO] argLine set to -javaagent:/home/fury/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=/home/fury/GitProjects/qp_web/server-side/target/test-results/coverage/jacoco/jacoco.exec -Djava.security.egd=file:/dev/./urandom -Xmx256m
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ arch-3-d ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 177 source files to /home/fury/GitProjects/qp_web/server-side/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ arch-3-d ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ arch-3-d ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ arch-3-d ---
[INFO] Surefire report directory: /home/fury/GitProjects/qp_web/server-side/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.qitsoftware.arch3d.config.WebConfigurerTest
2018-01-21 23:58:06.178  INFO   --- [           main] c.q.arch3d.config.WebConfigurer          : Web application configuration, using profiles: prod
2018-01-21 23:58:06.210  INFO   --- [           main] c.q.arch3d.config.WebConfigurer          : Web application fully configured
2018-01-21 23:58:06.306  INFO   --- [           main] c.q.arch3d.config.WebConfigurer          : Web application configuration, using profiles: dev
2018-01-21 23:58:06.307  INFO   --- [           main] c.q.arch3d.config.WebConfigurer          : Web application fully configured
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.347 sec - in com.qitsoftware.arch3d.config.WebConfigurerTest
Running com.qitsoftware.arch3d.repository.CustomAuditEventRepositoryIntTest

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster You have not to repeat the prefix : 
application
.

So this should be fine :

@Value("${hotspot.path.audio}")
private String audioPath;
▶ 打包
[信息]正在扫描项目。。。
[信息]
[信息]------------------------------------------------------------------------
[信息]建筑Arch 3 D 0.0.1-SNAPSHOT
[信息]------------------------------------------------------------------------
[信息]
[信息]---maven资源插件:3.0.1:复制资源(默认资源)@arch-3-d---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]正在复制62个资源
[信息]正在复制12个资源
[信息]
[信息]---maven资源插件:3.0.1:resources(默认资源)@arch-3-d---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]正在复制62个资源
[信息]正在复制12个资源
[信息]
[信息]---maven enforcer插件:1.4.1:enforce(强制版本)@arch-3-d---
[信息]
[信息]---JacocoMaven插件:0.7.9:准备代理(单元前测试)@arch-3-d---
[INFO]argLine设置为-javaagent:/home/fury/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=/home/fury/GitProjects/qp_web/server-side/target/test results/coverage/jacoco/jacoco.exec-Djava.security.egd=file:/dev//uradom-Xmx256m
[信息]
[信息]---maven编译器插件:3.6.0:编译(默认编译)@arch-3-d---
[信息]检测到更改-重新编译模块!
[信息]将177个源文件编译到/home/fury/GitProjects/qp_web/server-side/target/classes
[信息]
[信息]---maven资源插件:3.0.1:testResources(默认testResources)@arch-3-d---
[信息]使用“UTF-8”编码复制筛选的资源。
[信息]正在复制5个资源
[信息]正在复制1个资源
[信息]
[信息]---maven编译器插件:3.6.0:testCompile(默认testCompile)@arch-3-d---
[信息]无需编译-所有类都是最新的
[信息]
[信息]---maven surefire插件:2.18.1:test(默认测试)@arch-3-d---
[信息]Surefire报告目录:/home/fury/GitProjects/qp_web/server-side/target/Surefire报告
-------------------------------------------------------
T T S T S
-------------------------------------------------------
正在运行com.qitsoftware.arch3d.config.WebConfigurerTest
2018-01-21 23:58:06.178信息---[main]c.q.arch3d.config.webconfig配置程序:Web应用程序配置,使用配置文件:prod
2018-01-21 23:58:06.210信息---[main]c.q.arch3d.config.webconfig配置程序:Web应用程序已完全配置
2018-01-21 23:58:06.306信息---[main]c.q.arch3d.config.webconfig配置程序:Web应用程序配置,使用配置文件:dev
2018-01-21 23:58:06.307信息---[main]c.q.arch3d.config.webconfig配置程序:Web应用程序已完全配置
测试运行:9,失败:0,错误:0,跳过:0,运行时间:1.347秒-在com.qitsoftware.arch3d.config.webconfig测试中
正在运行com.qitsoftware.arch3d.repository.CustomAuditEventRepositoryIntTest
██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

::JHipster您不必重复前缀:
application

所以这应该是好的:

@ConfigurationProperties("application")

当您执行
/mvnw
时,我不确定它对您有何作用。它无法工作,因为您已指定

@Value("${hotspot.path.audio}")
 private String audioPath;
这意味着spring将搜索类似
application.application.hotspot.path.audio

它找不到

两种选择。
1.只需指定
@ConfigurationProperties

二,


我也试过了,但没用。你们看,这个应用程序很好用。问题是当我通过maven Tasks运行它时,您是否可以用整个输出(命令执行+异常)编辑您的问题?是的,添加了。看看:)很好!我认为YAML文件不在类路径中,mvnw可能会在运行spring引导应用程序时添加它。如果你可以编辑问题中的mvnw内容,这可能会有所帮助。不,不起作用。我已经应用了你的建议,但不知何故,该应用程序甚至与我的配置一起工作:你不应该在同一个类上混合使用
@Value
@ConfigurationProperties
<配置属性类上的code>@Component
也有点非典型。您可能希望在使用属性的类上使用
@EnableConfigurationProperties
▶ mvn package
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building Arch 3 D 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:copy-resources (default-resources) @ arch-3-d ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 62 resources
[INFO] Copying 12 resources
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:resources (default-resources) @ arch-3-d ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 62 resources
[INFO] Copying 12 resources
[INFO] 
[INFO] --- maven-enforcer-plugin:1.4.1:enforce (enforce-versions) @ arch-3-d ---
[INFO] 
[INFO] --- jacoco-maven-plugin:0.7.9:prepare-agent (pre-unit-tests) @ arch-3-d ---
[INFO] argLine set to -javaagent:/home/fury/.m2/repository/org/jacoco/org.jacoco.agent/0.7.9/org.jacoco.agent-0.7.9-runtime.jar=destfile=/home/fury/GitProjects/qp_web/server-side/target/test-results/coverage/jacoco/jacoco.exec -Djava.security.egd=file:/dev/./urandom -Xmx256m
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ arch-3-d ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 177 source files to /home/fury/GitProjects/qp_web/server-side/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:3.0.1:testResources (default-testResources) @ arch-3-d ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) @ arch-3-d ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ arch-3-d ---
[INFO] Surefire report directory: /home/fury/GitProjects/qp_web/server-side/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.qitsoftware.arch3d.config.WebConfigurerTest
2018-01-21 23:58:06.178  INFO   --- [           main] c.q.arch3d.config.WebConfigurer          : Web application configuration, using profiles: prod
2018-01-21 23:58:06.210  INFO   --- [           main] c.q.arch3d.config.WebConfigurer          : Web application fully configured
2018-01-21 23:58:06.306  INFO   --- [           main] c.q.arch3d.config.WebConfigurer          : Web application configuration, using profiles: dev
2018-01-21 23:58:06.307  INFO   --- [           main] c.q.arch3d.config.WebConfigurer          : Web application fully configured
Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.347 sec - in com.qitsoftware.arch3d.config.WebConfigurerTest
Running com.qitsoftware.arch3d.repository.CustomAuditEventRepositoryIntTest

        ██╗ ██╗   ██╗ ████████╗ ███████╗   ██████╗ ████████╗ ████████╗ ███████╗
        ██║ ██║   ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
        ██║ ████████║    ██║    ███████╔╝ ╚█████╗     ██║    ██████╗   ███████╔╝
  ██╗   ██║ ██╔═══██║    ██║    ██╔════╝   ╚═══██╗    ██║    ██╔═══╝   ██╔══██║
  ╚██████╔╝ ██║   ██║ ████████╗ ██║       ██████╔╝    ██║    ████████╗ ██║  ╚██╗
   ╚═════╝  ╚═╝   ╚═╝ ╚═══════╝ ╚═╝       ╚═════╝     ╚═╝    ╚═══════╝ ╚═╝   ╚═╝

:: JHipster You have not to repeat the prefix : 
application
.

So this should be fine :

@Value("${hotspot.path.audio}")
private String audioPath;
@ConfigurationProperties("application")
@Value("${hotspot.path.audio}")
 private String audioPath;