美文网首页Spring
创建springboot工程并修改maven镜像下载地址

创建springboot工程并修改maven镜像下载地址

作者: Scats | 来源:发表于2018-09-13 18:23 被阅读0次

一 新建工程

image.png
  • 选择对应模式


    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>
image.png
  • 插一句,这里文本编辑器是notepad++


    image.png
  • 打开工程,右下角如果弹出这个框,点击Enable Auto_import


    image.png
  • 依次点击打开IntelliJ IDEA->Settings ->Build, Execution, Deployment -> Build Tools > Maven(具体情况根据版本有所变化)


    image.png
  • 修改maven默认设置


    image.png

三 创建一个简单的实例

image.png
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
  • 右上角运行


    image.png
image.png

介绍到此,不足之处请不吝赐教,如有疑问,JustCallMe。

相关文章

网友评论

    本文标题:创建springboot工程并修改maven镜像下载地址

    本文链接:https://www.haomeiwen.com/subject/xfrggftx.html