springboot jsp项目 打包jar及发布

来源:互联网 发布:魔兽世界for mac 编辑:程序博客网 时间:2024/03/29 16:42

springboot打包jar并发布

1.pom修该打包方式 <packaging>jar</packaging>

2.配置打包插件,及打包的jdk版本,必须有打包插件才能打包

<plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>utf-8</encoding>
</configuration>
            </plugin>

3.pom配置对tomcat的支持

  <!--配置jsp jstl的支持-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>
        <!--添加对tomcat的支持-->
        <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-tomcat</artifactId>
  <scope>provided</scope>
        </dependency>
<!--对jsp的支持-->
        <dependency>
 <groupId>org.apache.tomcat.embed</groupId>
 <artifactId>tomcat-embed-jasper</artifactId>
 <scope>provided</scope>
</dependency>

4.打包时配置把webapp下的jsp打包到META-INF/resources路径下,在build标签下增加

<resources>
            <resource>
                <directory>src/main/webapp</directory>
                <targetPath>META-INF/resources</targetPath>
                <includes>
                    <include>**/**</include>
                </includes>
            </resource>
</resources>

5.静态资源放到springboot默认文件下就行了

6.打包maven package

7.Windows下,cmd 访问到放jar的路径下,执行java -jar xxxx.jar

8.linux下 命令一样   但是不会后台一直运行,后台执行命令   nohup java -jar xxx.jar  >日志输出文件.txt  &即可


0 0
原创粉丝点击