我开始使用maven创建一个Sping Boot 应用程序。
我不想使用maven命令部署项目。application.properties
spring.config.import=optional:file:env.properties
spring.datasource.url=${DATA_SOURCE_URL}
spring.datasource.username=${DB_USER}
spring.datasource.password=${DB_PASSWORD}
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.jpa.hibernate.ddl-auto = update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
jwt.secret = ${SECRET}
字符串
正如你所看到的,我导入了一个名为env.properties的文件,但是我不想每次使用mvn clean install命令时都导入它。
你能帮我找到正确的命令或配置我的pom.xml插件吗?
1条答案
按热度按时间3ks5zfa01#
您现在的位置:
要从
pom.xml
文件导入应用程序属性,您必须:在
<properties>
标记中设置参数和值的名称:字符串
第二个你必须加上
spring-boot-maven-plugin
和resource
,它们指向application.properties
。型
然后在
application.properties
文件中,您将能够访问参数作为下一个:型
另外,如果您不喜欢这种方法,可以使用Properties Maven Plugin