springboot打jar包
1.修改Packaging的打包方式
2.修改插件版本,并指定入口类的全限定名
3.将jsp文件打包到META-INF目录下
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.4.2.RELEASE</version> <configuration> <mainClass>Springboot1Application</mainClass> <layout>JAR</layout> </configuration> </plugin> </plugins> <resources> <!--打包时将jsp文件拷贝到META-INF目录下--> <resource> <!--指定resources插件处理那个目录下的资源文件--> <directory>src/main/webapp</directory> <!--注意此次必须要放在此目录下才能访问--> <targetPath>META-INF/resources</targetPath> <includes> <include>**/**</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/**</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/java</directory> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> </resources> </build>
4.maven-package 打包 maven-clean 删除
在打开jar所在的文件夹,输入cmd,jar - jar 项目名.jar运行
springboot打war包
1.将打包方式改成war
<packaging>war</packaging>
2.排除内嵌的tomcat
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3.引入jsp相关的jar
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
4.入口类继承SpringBootServletInitalizer