Intellij Idea新建SpringBoot項目方式
更新時間:2024年09月07日 09:44:43 作者:LI_AINY
這篇文章主要介紹了Intellij Idea新建SpringBoot項目方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
Intellij Idea新建SpringBoot項目
1.新建project

2.選擇

3.起名字

4.勾選web

5.選擇目錄 、名字 finsh

6.在pom.xml中添加依賴
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--
這個標(biāo)簽是在配置 Spring Boot 的父級依賴
有了這個,當(dāng)前的項目才是 Spring Boot 項目,spring-boot-starter-parent 是一個特殊的 starter ,
它用來提供相關(guān)的 Maven 默認(rèn)依賴,使用它之后,常用的包依賴就可以省去 version 標(biāo)簽。
-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ljw</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>test</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--Spring Boot 提供了熱部署的方式,當(dāng)發(fā)現(xiàn)任何類發(fā)生了改變,就會通過 JVM 類加載的方式,加載最新的類到虛擬機中-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 這個需要為 true 熱部署才有效 -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
7.新建一個helloWorld類

package com.ljw.test;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @RestController 注解: 該注解是 @Controller 和 @ResponseBody 注解的合體版
*/
@RestController
public class HelloWorld {
/**
* 測試類
*/
@RequestMapping("/hello")
public String hello() {
return "Hello Spring Boot!My First Page";
}
}
8.啟動自動生成的TestApplication類

9.訪問網(wǎng)址


總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
java集合中HashSet LinkedHashSet TreeSet三者異同面試精講
這篇文章主要為大家介紹了java集合中HashSet LinkedHashSet TreeSet三者異同面試精講,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-10-10
Springboot shiro認(rèn)證授權(quán)實現(xiàn)原理及實例
這篇文章主要介紹了Springboot shiro認(rèn)證授權(quán)實現(xiàn)原理及實例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-06-06
Java使用EasyExcel模版導(dǎo)出詳細(xì)操作教程
業(yè)務(wù)中經(jīng)常需要按照一個特定的模板導(dǎo)出特定內(nèi)容,有些單元格還要求特殊的格式,所以下面這篇文章主要給大家介紹了關(guān)于Java使用EasyExcel模版導(dǎo)出的相關(guān)資料,需要的朋友可以參考下2023-10-10
SpringCloud如何根據(jù)服務(wù)名獲取服務(wù)運行實例并進行負(fù)載均衡
文章介紹了SpringCloud中使用Nacos作為注冊中心時,服務(wù)注冊和發(fā)現(xiàn)的過程,以及如何通過DiscoveryClient接口和LoadBalancerClient類進行服務(wù)的負(fù)載均衡,感興趣的朋友跟隨小編一起看看吧2025-01-01

