idea使用maven创建springboot项目

您所在的位置:网站首页 idea怎么导入war包运行 idea使用maven创建springboot项目

idea使用maven创建springboot项目

2023-06-20 13:56| 来源: 网络整理| 查看: 265

1.首先打开IDEA后点击file->settings ,然后在VM Options内添加 -DarchetypeCatalog=internal 运行参数 这个参数是让项目读取本地maven仓库,而不是远程仓库。

2.点击file->New->Project

3.选择maven,不从任何模板创建。

4. groupid表示项目的包名,artifactid表示项目名,Location是项目地址

5. 选择maven版本和配置文件等,点击finish。

6.简单的maven结构就创建完成了

pom文件:

4.0.0

org.example springboot-maven 1.0-SNAPSHOT

org.springframework.boot spring-boot-starter-parent 2.6.1   org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin

7、编写springboot项目启动类,并加入SpringBootApplication注解

package com.demo;

import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication public class SpringbootDemoApp {     public static void main(String[] args) {         SpringApplication.run(SpringbootDemoApp.class,args);     }

}      8、编写测试Controller类,加入相关注解 @RestController public class HelloController {

@GetMapping() public String root(){ return “spring boot root path”; }

@GetMapping(“/hello”) public String hello(){ return “hello Springboot”; } }

运行程序,显示出内容。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3