一 新建工程

-
选择对应模式
image.png
-
暂时先全部默认
image.png
-
勾选web
image.png
-
自行命名
image.png
-
意思是窗口留在旧工程,还是新工程
image.png
二修改maven镜像
-
在这个路径下新建一个setting.xml文件
image.png
- 用txt打开复制以下内容并保存
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>

-
插一句,这里文本编辑器是notepad++
image.png
-
打开工程,右下角如果弹出这个框,点击Enable Auto_import
image.png
-
依次点击打开IntelliJ IDEA->Settings ->Build, Execution, Deployment -> Build Tools > Maven(具体情况根据版本有所变化)
image.png
-
修改maven默认设置
image.png
三 创建一个简单的实例


- 输入下列代码
package com.example.demo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class Example {
@RequestMapping(value = "index")
public String index() {
return "欢迎来到王者荣耀";
}
}

-
右上角运行
image.png

- 在浏览器输入
http://localhost:8080/index
image.png
介绍到此,不足之处请不吝赐教,如有疑问,JustCallMe。
网友评论