1. jar包方式启动
1. 添加依赖
代码语言:javascript复制<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
2. 生成jar包
- Eclipse:pom.xml,选择 run as -> maven install
- IDEA:选择 View -> Tool Windows -> Maven Projects -> 项目 -> Lifecycle -> install,然后点击Maven Projects窗体上方的运行按钮
3. 运行项目jar包(命令行命令)
代码语言:javascript复制> java -jar xxx.jar
4. 目录结构
官方介绍
2. war包方式启动
1. 修改配置
2. 修改启动类
代码语言:javascript复制package com.shadowolf.base_project;
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 BaseProjectApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(BaseProjectApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(BaseProjectApplication.class, args);
}
}
3. 生成war包
- Eclipse:右键点击pom.xml,选择 run as -> maven install
- IDEA:选择 View -> Tool Windows -> Maven Projects -> 项目 -> Lifecycle -> install,然后点击Maven Projects窗体上方的运行按钮
4. tomcat运行测试
- 将target目录下的xxx.war放到tomcat/webapps目录下
- 启动tomcat
- 访问 localhost:8080/项目名/mapping地址(例如:http://localhost:8080/base_project/api/v1/order)
3. 启动容器介绍和第三方测试数据讲解
地址