1,下载idea,maven依赖仓库,mysql数据库,tomcat服务器
2,在idea上选择File -> Settings -> 搜索maven -> 修改maven中的setting.xml,设置使用阿里云下载依赖
<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>
3,在idea上选择File -> New -> projec t-> Spring Initializr -> 填写项目名这类的配置 -> 选择Spring Web依赖
4,选择配置编码UTF-8
5,在XxxApplication的同文件夹下,创建controller文件夹,再创建controller/IndexController
@RestController @CrossOrigin public class IndexController { @GetMapping("/ok") public String index(){ return "ok"; } }
6,接着就可以在浏览器输入localhost:8080/ok,即可看到浏览器上显示ok的文字
如果对我的其它文章有更多的兴趣,可以访问我的个人博客:uniqueho.xyz