我可以创建Azure ops管道,但是我的问题是我已将代码检入到不应在其中检入应用程序属性文件的存储库中。
这意味着在部署时,在正确部署到应用程序引擎之前,我应该必须从某个安全的地方下载应用程序属性文件并构建我的spring boot应用程序。
所以,到目前为止,我是在运行时将应用程序属性文件下载到azure代理中的。我将属性文件传递给了maven build命令,但没有成功。 [注意:我已经搜索了很多,读了很多答案,并且也应用了,但是没有用。]
我使用的命令行:
mvn -f myapp-springboot-api / pom.xml-Dspring-boot.run.jvmArguments =“-Dspring.config.location = file:/home/username/application.properties”干净的包appengine:deploy
我也尝试过
mvn -f myapp-springboot-api / pom.xml--spring.config.location =文件:/ home /用户名/application.properties干净的包appengine:deploy
这也没有锻炼。
而且,我尝试通过pom.xml传递整个属性文件的位置
pom.xml更改:
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>1.1.1.RELEASE</spring-cloud.version>
<property.file.location>${property.file.location}</property.file.location>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-1</version>
<configuration>
<files>
<file>${property.file.location}</file>
</files>
</configuration>
</plugins>
</build>
比起我尝试建立:
mvn -f myapp-springboot-api / pom.xml-Dproperty.file.location =“ / home / username / application.properties”清洁程序包appengine:deploy
而且我也无法加载定义的外部属性文件。
感谢您,谢谢您的帮助。
您正在使用的命令实际上不会将外部属性文件传递给应用程序引擎(因为它存在于另一台服务器上,而仅适用于正在打包+部署的正在运行的Maven进程。
因此,如果您在构建之前已将属性文件复制到外部代理,那么我将替换已签入源代码管理的默认文件。
因此您的构建步骤将是例如:
mv /home/username/application.properties myapp-springboot-api/src/main/resources/application.properties
mvn -f myapp-springboot-api/pom.xml clean package appengine:deploy
所以现在您已编译和部署的jar文件将包括新的属性文件,最近出现的另一种选择是使用Azure App Configuration之类的东西。
如果您不必执行其他命令,也可以使用Maven Resources Plugin为您执行复制。