springboot the jar and war

springboot jar packaging

1. The modification of a packaging Packaging

2. Modify the plug-in version, and specify the fully qualified class name of the inlet

3. The package jsp file to the META-INF directory

<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>
                <!- Specify the resources plug-in processing resource files in that directory -> 
                <Directory> src / main / the webapp </ Directory>
                <! - Note that this must be placed in this directory to access ->
                <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 package maven-clean deleted

 Open the jar file in the same folder, type cmd, jar - jar project name .jar run

springboot fight the war package

1. are packaged into war

<packaging>war</packaging>

2. exclude embedded 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. The introduction of jsp related 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. The inlet class inheritance SpringBootServletInitalizer

 

 

 

 

Guess you like

Origin www.cnblogs.com/ghwq/p/12624657.html