1. 程式人生 > >springboot war包匯出

springboot war包匯出

  1. 由jar變成war
    <packaging>war</packaging>
  2. web依賴去除tomcat

        <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId
    >
    org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
  3. 新增SpringBootStartApplication

    • 其中Demo1Application.class為原@SpringBootApplication啟動類
      package com.trs.stratup;
      import
      org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; public class SpringBootStartApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { // TODO Auto-generated method stub
      return builder.sources(Demo1Application.class); } }
  4. 因為有本地依賴的檔案所以將依賴路徑加入pom.xml

    • lib在pom同級路徑下
                  <plugin>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>2.3.2</version>
                      <configuration>
                          <source>1.7</source>
                          <target>1.7</target>
                          <encoding>UTF-8</encoding>
                          <compilerArguments>
                              <extdirs>lib</extdirs>
                          </compilerArguments>
                      </configuration>
                  </plugin>
  5. 使用mvn clean package打包