idea使用maven创建springboot项目
1.首先打开IDEA后点击file->settings ,然后在VM Options内添加 -DarchetypeCatalog=internal 运行参数 这个参数是让项目读取本地maven仓库,而不是远程仓库。
2.点击file->New->Project
3.选择maven,不从任何模板创建。
4. groupid表示项目的包名,artifactid表示项目名,Location是项目地址
5. 选择maven版本和配置文件等,点击finish。
6.简单的maven结构就创建完成了
pom文件:
4.0.0
org.example springboot-maven 1.0-SNAPSHOT
org.springframework.boot spring-boot-starter-parent 2.6.1 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin7、编写springboot项目启动类,并加入SpringBootApplication注解
package com.demo;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication public class SpringbootDemoApp { public static void main(String[] args) { SpringApplication.run(SpringbootDemoApp.class,args); }
} 8、编写测试Controller类,加入相关注解 @RestController public class HelloController {
@GetMapping() public String root(){ return “spring boot root path”; }
@GetMapping(“/hello”) public String hello(){ return “hello Springboot”; } }
运行程序,显示出内容。