1.打包jar
<packaging>jar</packaging>
<build> <!-- 定义包含这些资源文件,能在jar包中获取这些文件 --> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> <include>**/*.yml</include> </includes> <!--是否替换资源中的属性--> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.*</include> </includes> <!--是否替换资源中的属性--> <filtering>false</filtering> </resource> </resources> <!-- 应与application.properties(或application.yml)中context-path保持一致 使用idea生成war包:在idea菜单栏中找到Buildbuild Arufacts生成war,生成的war包会在target文件夹中找到 --> <!--<finalName>war包名称</finalName>--> <plugins> <!--热部署--> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <!-- 如果没有该配置,devtools不会生效 --> </configuration> </plugin> <!--打包成可执行jar--> <!--打包成可执行jar--> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!-- 指定该Main Class为全局的唯一入口 --> <mainClass>com.jit.Application</mainClass> <!--<layout>ZIP</layout>--> </configuration> <executions> <execution> <goals> <goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中--> </goals> </execution> </executions> </plugin> </plugins> </build>
public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
mvn clean install -Dmaven.test.skip=true
2.打包war