使用maven方式創(chuàng)建springboot項(xiàng)目的方式
使用Spring Initializr創(chuàng)建spring boot項(xiàng)目,因?yàn)橥饩W(wǎng)問題導(dǎo)致很難成功,所以只能使用maven方式,這里介紹下該方式。
壹、創(chuàng)建maven項(xiàng)目
1.創(chuàng)建項(xiàng)目

2.選擇maven類型,jdk版本,空模板

3.填寫項(xiàng)目名稱,本地存儲路徑,group信息,版本等信息

4.項(xiàng)目結(jié)構(gòu)

貳、整改為springboot項(xiàng)目
1.修改pom.xml:繼承spring-boot-starter-parent;自行修改版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
<relativePath/>
</parent>

2.修改pom.xml:添加打打包方式
<packaging>jar</packaging>

3.修改pom.xml:添加spring-boot-starter-web依賴包
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

4.修改pom.xml:添加jar包啟動入口類
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.te.TestWebApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>

5.完整的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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.12.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.te</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.te.TestWebApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
6.創(chuàng)建Springboot啟動類,并添加注解和main方法
package com.te;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class TestWebApplication {
public static void main(String[] args) {
SpringApplication.run(TestWebApplication.class, args);
}
}
根據(jù)功能需要:添加其他jar包依賴;創(chuàng)建application.yml、application.properties等文件添加配置項(xiàng)等等

叁、測試 創(chuàng)建測試類
package com.te.web;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@GetMapping("/test")
public String test() {
return "hello world";
}
}啟動springboot項(xiàng)目,第一次啟動類的方式,后面可以使用快捷方式啟動


頁面訪問測試,地址:http://localhost:8080/test

到此這篇關(guān)于使用maven方式創(chuàng)建springboot項(xiàng)目的文章就介紹到這了,更多相關(guān)maven方式創(chuàng)建springboot內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
詳解java數(shù)組進(jìn)行翻轉(zhuǎn)的方法有哪些
這篇文章主要介紹了詳解java數(shù)組進(jìn)行翻轉(zhuǎn)的方法有哪些,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01
Spring細(xì)數(shù)兩種代理模式之靜態(tài)代理和動態(tài)代理概念及使用
代理是一種設(shè)計模式,提供了對目標(biāo)對象另外的訪問方式,即通過代理對象訪問目標(biāo)對象??梢圆恍薷哪繕?biāo)對象,對目標(biāo)對象功能進(jìn)行拓展。在我們學(xué)習(xí)Spring的時候就會發(fā)現(xiàn),AOP(面向切面編程)的底層就是代理2023-02-02
Mybatis Plus Wrapper查詢某幾列的方法實(shí)現(xiàn)
MybatisPlus中,使用Wrapper的select和notSelect方法可以精確控制查詢的字段,本文就來介紹一下Mybatis Plus Wrapper查詢某幾列的方法實(shí)現(xiàn),感興趣的可以了解一下2024-10-10
手寫redis@Cacheable注解?參數(shù)java對象作為key值詳解
這篇文章主要介紹了手寫redis@Cacheable注解?參數(shù)java對象作為key值詳解,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-01-01
淺談java字符串比較到底應(yīng)該用==還是equals
這篇文章主要介紹了淺談java字符串比較到底應(yīng)該用==還是equals,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
Java使用easyExcel批量導(dǎo)入數(shù)據(jù)詳解
這篇文章主要介紹了Java使用easyExcel批量導(dǎo)入數(shù)據(jù)詳解,通常我們會提供一個模板,此模塊我們可以使用easyExcel導(dǎo)出數(shù)據(jù)生成的一個Excel文件當(dāng)作模板,提供下載鏈接,用戶在該文件內(nèi)填入規(guī)定的數(shù)據(jù)格式以后可以批量導(dǎo)入數(shù)據(jù)到數(shù)據(jù)庫中,需要的朋友可以參考下2023-08-08

