不需要勾选Create from archetype
改造成SpringBoot项目 1. pom.xml的project标签加入父依赖2. 加入web依赖包org.springframework.boot spring-boot-starter-parent 2.5.5
3. 新建启动类org.springframework.boot spring-boot-starter-web
package com.app;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ApplicationStartup
{
public static void main(String[] args) {
SpringApplication.run(ApplicationStartup.class, args);
}
}
4. 新建WEB测试接口
package com.app.test;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/TestClass")
public class Test {
@GetMapping("TestFunction")
@ResponseBody
public String onMethod() {
return "return some json";
}
}
5.输入url观察结果
http://localhost:8080/TestClass/TestFunction
6. 打包运行pom.xml的project标签中加入插件,用来运行指定的启动类com.app.ApplicationStartup的main方法
org.springframework.boot spring-boot-maven-plugin com.app.ApplicationStartup
依次执行maven命令
clean 清空之前运行生成的target目录
package 打jar包
在target目录找到生成的jar包
把jar包拷贝到其他地方进行cmd运行
java -jar boot_001-1.0-SNAPSHOT.jar



