1.修改Maven的配置文件:C:\maven\apache-maven-3.8.1\conf\settings.xml
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
2.确定自己已经配置好了Maven,并且在IDEA中自定义->所有设置->已经配置构建工具:
mvn -v
3.新建项目 -> Maven -> 下一步->
4.下面是默认的配置:
5.导入boot配置:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
</parent>
6.导入依赖:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
然后,点一下加载Maven依赖
然后左边就会加载依赖包:
7.然后创建一个主程序类:
/**
* 主程序类
* @SpringBootApplication 注解表示这是一个SpringBoot应用
*/
@SpringBootApplication
public class MainApplication
{
public static void main(String[] args)
{
SpringApplication.run(MainApplication.class, args);
}
}
8.再创建一个类:
@RestController
public class HelloContorller
{
@RequestMapping("/hello")
public String handle01()
{
return "Hello, Spring Boot 2!";
}
}
9.直接运行main方法: