到此为止,Maven 与 仓库配置以及完成。
[](
)IDEA 配置 Maven
打开 IDEA,点击开始右下角的 Configure -> Settings 进入设置;
设置界面:Build, Execute, Deployment->Build Tools->Maven;
修改 Maven home directory: D:JavaDevelopMavenapache-maven-3.5.0
修改 User settings file: D:JavaDevelopMavenapache-maven-3.5.0confsettings.xml
只要 settings.xml 中配置的正确,Local repository 会被自动识别到;
至此,IDEA 配置 Maven 已经完全结束了,可以开始创建项目了。
[](
)IDEA 创建 springboot 项目
========================================================================================
打开 IDEA,Create New Project,选择 Maven 项目,勾选 Create from archetype,选中 maven-archetype-webapp;
GruopId 其实就是默认的包名;
确认 Maven home directory 是我们自己的 Maven 位置,包括下面的 User settings file 和 Local repository 都是我们自己的文件目录;勾上 Override;
点击 Finsh,开始创建项目;
如果右下角跳出选项,选择 Auto Enable;
首先 pom.xml 中引入项目依赖:
这些是随时会更新的,建议去看 [springboot官方文档](
);
org.springframework.boot
spring-boot-starter-parent
2.2.5.RELEASE
org.springframework.boot
spring-boot-starter-web
junit
junit
4.11
test
将 springboot 配置成标准目录结构:
Application.java:
package com.yusael;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
@EnableAutoConfiguration // 作用: 开启自动配置 初始化spring环境 springmvc环境
@ComponentScan // 作用: 用来扫描相关注解 扫描范围 当前入口类所在的包及子包(com.yusal及其子包)
public class Application {
public static void main(String[] args) {
// springApplication: spring应用类 作用: 用来启动springboot应用
// 参数1: 传入入口类 类对象 参数2: main函数的参数
SpringApplication.run(Application.class, args);
}
}
helloController.java:
package com.yusael.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/hello")
public class helloController {



