dubbo-maven打可执行jar包
程序员文章站
2022-05-01 12:39:47
...
<build>
<finalName>dubbo-provider</finalName>
<resources>
<resource>
<!--将resources文件中的所有xml文件和properties文件打入到classes文件中-->
<targetPath>${project.build.directory}/classes</targetPath>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<!--结合com.alibaba.dubbo.container.Main-->
<!--dubbo的spring Container启动时,自动加载META-INF/spring目录下的所有Spring配置-->
<!--配置:(配在java命令-D参数或dubbo.properties中)-->
<!--dubbo.spring.config=classpath*:META-INF/spring/*.xml一配置spring配置加载位置-->
<targetPath>${project.build.directory}/classes/META-INF/spring</targetPath>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>ApplicationContext.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<!--打jar包时,配置manifest文件,加入lib包的jar依赖-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classesDirectory>target/classes</classesDirectory>
<archive>
<manifest>
<mainClass>com.alibaba.dubbo.container.Main</mainClass>
<!--打包manifest.MF文件不记录的时间戳版本-->
<useUniqueVersions>false</useUniqueVersions>
<addClasspath>true</addClasspath>
<classpathPrefix>lib</classpathPrefix>
</manifest>
<manifestEntries>
<Class-path>.</Class-path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<!--把jar包放到项目目录下的lib目录下-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeTypes>jar</includeTypes>
<!--<useUniqueVersion>false</useUniqueVersion>-->
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>