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

SpringBoot將項(xiàng)目打成war包步驟解析

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

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.添加啟動(dòng)類

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.右鍵項(xiàng)目依次執(zhí)行Run As -> Maven Clean 和 Maven Install,會(huì)在target目錄下生成war包

5.安裝Tomcat(注意:項(xiàng)目里面的端口和Tomcat保持一致,建議為8080,否則到時(shí)訪問(wèn)url會(huì)報(bào)錯(cuò))

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

啟動(dòng)Tomca,會(huì)自動(dòng)將War包生成文件夾

6.訪問(wèn)路徑

注意:訪問(wèn)路徑要加上項(xiàng)目名稱

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

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

化州市| 新兴县| 肥西县| 贵南县| 社会| 库尔勒市| 松江区| 康保县| 定结县| 罗定市| 绍兴县| 沿河| 建瓯市| 东海县| 米泉市| 东光县| 三原县| 佛坪县| 长宁县| 喀喇沁旗| 满洲里市| 赤水市| 阳江市| 桑植县| 永新县| 时尚| 乐安县| 区。| 漳平市| 鄯善县| 丹巴县| 和林格尔县| 榕江县| 通辽市| 株洲市| 黄浦区| 蒙山县| 额尔古纳市| 仲巴县| 岫岩| 乡宁县|