idea创建springboot项目
1.
下一步
下一步
存放位置自行修改
2.编写一个controller
package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@RequestMapping("/hello")
public String hello() {
return "Hello Spring Boot!";
}
}
3.运行DemoApplication.java
3.项目打成jar包
上面打包方式的前提是项目使用了 spring-boot-starter-parent 作为 parent,不过在大部分项目中,项目的 parent 可能并不是 spring-boot-starter-parent,而是公司内部定义好的一个配置,此时 spring-boot-maven-plugin 插件并不能直接使用,我们只要做如下额外的配置即可。配置完毕后就和之前一样,可以通 Maven 命令或者 IntelliJ IDEA 中的 Maven 插件进行打包。
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
4.运行jar包
java -jar demo-0.0.1-SNAPSHOT.jar