我有一个maven战争项目。在这个项目中,我包括两个依赖项,如
<parent>
<groupId>com.softech.ls360.proxy</groupId>
<artifactId>LS360ProxyAPI</artifactId>
<version>0.0.1</version>
</parent>
<artifactId>LS360ProxyAPIWeb</artifactId>
<packaging>war</packaging>
...
<properties>
...
<tomcat-directory-path>D:\Basit\apache-tomcat-8.0.18</tomcat-directory-path>
</properties>
<dependencies>
<dependency>
<groupId>com.softech.ls360.proxy</groupId>
<artifactId>LmsProxy</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.softech.ls360.proxy</groupId>
<artifactId>StoreFrontProxy</artifactId>
<version>0.0.1</version>
</dependency>
....
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>${project.artifactId}</warName>
<outputDirectory>${tomcat-directory-path}\webapps</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
现在当我制作war文件时,WEB-INF/lib
文件夹包含其他依赖项jars以及LmsProxy-0.0.1.jar
和StoreFrontProxy-0.0.1.jar
文件。现在我想要LmsProxy-0.0.1.jar
和StoreFrontProxy-0.0.1.jar
,我排除了包含.vm, .xml and .properties file
的所有资源。实际上在我的LmsProxy-0.0.1.jar
文件中,我有关于Web服务和数据库的属性文件。同样在我的StoreFrontProxy-0.0.1.jar
我有关于Web服务的属性文件。
现在发生了什么,当war文件生成并且web服务器运行时,然后在WEB-INF\lib
文件夹中有jar。我需要打开那个jar并更改我的属性文件然后再制作jar文件。
我希望我的属性文件在jar之外。我只是更改属性或我想在配置文件中更改的任何内容,就是这样。重启服务器,一切正常。
如何使用maven war plugin
或任何其他插件执行此操作。我看到maven-overlay-plugin
但我认为它只适用于战争类型依赖。我有类型为JAR的依赖项。
由于
修改 -------------
LMSProxy.pom
<parent>
<groupId>com.softech.ls360.proxy</groupId>
<artifactId>LS360ProxyAPI</artifactId>
<version>0.0.1</version>
</parent>
<artifactId>LmsProxy</artifactId>
<name>LmsProxy</name>
...
<properties>
<maven-dependency-plugin.version>2.9</maven-dependency-plugin.version>
<maven-jar-plugin.version>2.5</maven-jar-plugin.version>
</properties>
<dependencies>
</dependencies>
<plugins>
<!-- uses maven-dependency-plugin to copy all dependencies to "target/lms-proxy-dependency-jars/"
folder, and defines the dependency classpath with maven-jar-plugin
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>
org.springframework, org.springframework.ws, org.springframework.data,
org.springframework.security, org.aspectj, javax.servlet, javax.servlet.jsp,
javax.inject, javax.validation, org.hibernate, org.jadira.usertype,
com.microsoft.sqlserver, joda-time, com.google.guava, org.apache.httpcomponents,
org.apache.commons, com.fasterxml.jackson.core, com.fasterxml.jackson.module,
com.fasterxml.jackson.datatype, org.jvnet.jaxb2_commons, org.slf4j, log4j,
org.hamcrest, junit, org.mockito, com.jayway.jsonpath
</includeGroupIds>
<outputDirectory>${project.build.directory}/lms-proxy-dependency-jars/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<!-- To make jar file like a exe file, you need to define a manifest file and declare the application
entry point inside via maven-jar-plugin in pom.xml.
- create executable JAR with the specified mainClass
- exclude all .properties files located in src/main/resources from the JAR
- add conf folder to the manifest, providing access to it from your executable JAR
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<!-- The configuration of the plugin -->
<configuration>
<excludes>
<exclude>**/*.properties</exclude>
<exclude>**/*.xml</exclude>
<exclude>**/*.vm</exclude>
</excludes>
<!-- Configuration of the archiver -->
<archive>
<!-- Manifest specific configuration -->
<manifest>
<!-- Classpath is added to the manifest of the created jar file. -->
<addClasspath>true</addClasspath>
<!--
Configures the classpath prefix. This configuration option is
used to specify that all needed libraries are found under Lms-Proxy-Dependency-jars/
directory.
Use “classpathPrefix” to specify folder name in which all properties will be placed.
-->
<classpathPrefix>lms-proxy-dependency-jars/</classpathPrefix>
<!-- Specifies the main class of the application -->
<mainClass>com.softech.ls360.lms.proxy.LmsProxy</mainClass>
</manifest>
<!-- Use “Class-Path” to specify the folder. “.” Indicate current folder, while
“propertiesFiles” specifies “propertiesFiles” folder in same directory as JAR.
-->
<manifestEntries>
<Class-Path>lms-proxy-conf/</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- copy all .properties, .xml and .vm files located in src/main/resources into a conf folder in your project root. Note that this
step is an optional convenience for your users of the JAR. You can require the explicitly create this file in the
conf directory. This conf directory is effectively added to your runtime classpath via the manifest.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/lms-proxy-conf</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.vm</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>