赞
踩
在pom.xml添加代码:
<build> <finalName>App</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>这里填完整入口类名</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build>
这个不能解决maven引用的库也打包到目标jar里
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.1</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> <manifestEntries> <Main-Class> 主类名称 </Main-Class> </manifestEntries> </archive> </configuration> </plugin>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.0.1.RELEASE</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
打包命令:
mvn package spring-boot:repackage
<plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.1.0</version> <executions> <execution> <id>copy-resources</id> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${project.build.directory}</outputDirectory> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin>
<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.*</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> <filtering>true</filtering> <!-- <excludes> <exclude>*.properties</exclude> <exclude>*.xml</exclude> <exclude>*.db</exclude> </excludes> --> </resource> <resource> <directory>src/main/webapp</directory> <includes> <include>**/*.*</include> </includes> <filtering>true</filtering> </resource> </resources>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。