Sping Boot 项目的本质其实还是一个 Maven 项目,项目创建通常有三种方式,Spring官方提供的在线Spring Initializr工具创建、IntelliJ IDEA 创建[通过开发工具创建]、以及Maven 创建。
打开https://start.spring.io/ 生成 Spring Boot 项目。
此实际原理同上
通过引入springboot的依赖。
新建maven
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
org.example
springboot-demo
1.0-SNAPSHOT
UTF-8
1.8
1.8
org.springframework.boot
spring-boot-starter-parent
2.6.7
org.springframework.boot
spring-boot-starter-web
org.apache.maven.plugins
maven-compiler-plugin
2.5
${maven.compiler.source}
${maven.compiler.target}
UTF-8
package cn.javaxxw.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 功能描述: 启动类
* @author Trazen
* @date 2022/5/18 15:46
*/
@SpringBootApplication
@RestController
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class,args);
}
@GetMapping("/test")
public String index() {
return "Hello World!";
}
}
留言与评论(共有 0 条评论) “” |