最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot將項目打成war包步驟解析

 更新時間:2020年03月13日 13:48:29   作者:玉天恒  
這篇文章主要介紹了SpringBoot將項目打成war包步驟解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

1.修改pom.xml文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>top.ytheng</groupId>
 <artifactId>springboot-demo</artifactId>
 <version>0.0.1</version>
 <packaging>war</packaging>
 
 <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>
  

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <optional>true</optional>
       <scope>true</scope>
    </dependency>
  </dependencies>

  <build>
    <finalName>myspringboot</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

2.添加控制器Controller

package top.ytheng.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/file")
public class FileController {

  @RequestMapping("/testpath")
  @ResponseBody
  private Object testPath() {
    return "Success";
  }
  
}

3.添加啟動類

package top.ytheng.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
  
  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(DemoApplication.class);
  }
  
  public static void main(String[] args) throws Exception {
    SpringApplication.run(DemoApplication.class, args);
  }
}

4.右鍵項目依次執(zhí)行Run As -> Maven Clean 和 Maven Install,會在target目錄下生成war包

5.安裝Tomcat(注意:項目里面的端口和Tomcat保持一致,建議為8080,否則到時訪問url會報錯)

將War包拷貝到Tomcat的webapps目錄下面

啟動Tomca,會自動將War包生成文件夾

6.訪問路徑

注意:訪問路徑要加上項目名稱

http://localhost:8080/myspringboot/file/testpath

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

土默特右旗| 隆尧县| 隆昌县| 丹阳市| 来宾市| 油尖旺区| 凤山县| 清新县| 聂拉木县| 馆陶县| 宿州市| 崇仁县| 武穴市| 芦山县| 平罗县| 桑日县| 西宁市| 和政县| 拜城县| 黄龙县| 中江县| 咸宁市| 乡宁县| 陇南市| 台江县| 驻马店市| 郁南县| 卢氏县| 盖州市| 时尚| 武山县| 象州县| 盐山县| 江油市| 临漳县| 沂源县| 专栏| 毕节市| 枞阳县| 尖扎县| 长治县|