我有一个春季启动应用程序。当我单击 SpringToolSuit4 中的“运行”按钮时,它可以正常工作。
但是当我运行“maven install”时,我收到错误消息:
<error message="Failed to load ApplicationContext" type="java.lang.IllegalStateException">java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'envVersionNum' in value "${envVersionNum}"
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'envVersionNum' in value "${envVersionNum}"
</error>
Run Code Online (Sandbox Code Playgroud)
我的应用程序属性的内容:
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.jpa.show-sql=true
spring.thymeleaf.cache=false
version=${envVersionNum}
Run Code Online (Sandbox Code Playgroud)
如果我把它改成
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.jpa.show-sql=true
spring.thymeleaf.cache=false
version=1.1.1
Run Code Online (Sandbox Code Playgroud)
效果很好。但我想从用户那里获取 envVersionNum,它存储在 .bash_profile 中(导出 envVersionNum= 1.1.1)。
pom.xml的内容:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> …Run Code Online (Sandbox Code Playgroud)