在 Wildfly 服务器中部署 Spring Boot WAR 时如何外部化 .properties 文件?
How to externalise .properties files when deploying a Spring Boot WAR in Wildfly Server?
我正在使用 Spring Boot 开发 Web 应用程序,并希望生成 war 而不是 jar。
使用此处描述的从 jar 到 war 的转换工作正常:http://spring.io/guides/gs/convert-jar-to-war/
但我想从 war 中外部化 application.properties,因为我希望能够在不打开 war 存档的情况下修改它。
我已经定义了 spring-boot-maven 插件。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>
com.application.Application
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
我想我需要将 Dependency: config
添加到我的清单文件中。
所以,我是这样做的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>config</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
但是当我在 Wildfly 8.4 上启动 Application.war 时,我得到了这个
{"JBAS014671: Failed services" => {"jboss.module.service.\"deployment.Application.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.screening.war\".main: JBAS018759: Failed to load module: deployment.Application.war:main
Caused by: org.jboss.modules.ModuleNotFoundException: config:main"}}
我希望我的应用程序以我的自定义 MANIFEST.MF(具有依赖项:配置)开始,以便我可以外部化我的 application.properties 文件。
谢谢。
问题出在服务器端!
当你指定一个包时,你需要添加一个module.xml文件与Wildfly服务器。
所以在 modules/config/main/
中,我添加了 application.properties 和 module.xml包含的文件:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="config">
<resources>
<resource-root path="."/>
</resources>
</module>
感谢@NielsNet 的回复。
我正在使用 Spring Boot 开发 Web 应用程序,并希望生成 war 而不是 jar。 使用此处描述的从 jar 到 war 的转换工作正常:http://spring.io/guides/gs/convert-jar-to-war/
但我想从 war 中外部化 application.properties,因为我希望能够在不打开 war 存档的情况下修改它。
我已经定义了 spring-boot-maven 插件。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>
com.application.Application
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
我想我需要将 Dependency: config
添加到我的清单文件中。
所以,我是这样做的:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Dependencies>config</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
但是当我在 Wildfly 8.4 上启动 Application.war 时,我得到了这个
{"JBAS014671: Failed services" => {"jboss.module.service.\"deployment.Application.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.screening.war\".main: JBAS018759: Failed to load module: deployment.Application.war:main
Caused by: org.jboss.modules.ModuleNotFoundException: config:main"}}
我希望我的应用程序以我的自定义 MANIFEST.MF(具有依赖项:配置)开始,以便我可以外部化我的 application.properties 文件。
谢谢。
问题出在服务器端!
当你指定一个包时,你需要添加一个module.xml文件与Wildfly服务器。
所以在 modules/config/main/
中,我添加了 application.properties 和 module.xml包含的文件:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="config">
<resources>
<resource-root path="."/>
</resources>
</module>
感谢@NielsNet 的回复。