最近用IDEA插件創建Springboot項目,總是403,估計被牆了!

那么這里在提供兩種方法
1.從官網下載模板,導入IDEA內
2.使用Maven創建
方法一:打開 https://start.spring.io/ 選擇Springboot版本 寫上包名 項目命 點擊Generate Project 下載項目導入IDEA。(這種方法下載的工程可能是SpringBoot java工程,檢查SpringBootSpringBoot框架開發web項目的起步依賴是否帶web spring-boot-starter-web 如第二張圖,如果不帶添加即可)


方法二:
通過Maven
(1)簡單說一下創建,大概流程就是創建一個Maven項目,在pom文件里面添加SpringBoot父級依賴,啟動依賴,啟動測試依賴!
這里我用原型創建Maven項目




(2)在pom.xml里面添加 SpringBoot框架的父級依賴 SpringBoot框架開發web項目的起步依賴 測試依賴


添加好之后,在com.springboot包下創建類Application Springboot工程的主類(放在其他業務子類的外面)
編寫main方法 加上注解

貼代碼:
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication //springboot的全局的自動配置注解 public class Application { public static void main(String[] args) { // 固定的代碼 啟動springboot程序 初始化spring容器 SpringApplication.run(Application.class, args); } }
創建一個controller 進行測試

右擊Application類 DeBug運行
測試結果

pom文件完整配置:
<?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> <!--繼承了SpringBoot框架的父級依賴--> <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.demo.springboot</groupId> <artifactId>01-springboot-web</artifactId> <version>0.0.1-SNAPSHOT</version> <name>02-springboot-mybatis</name> <description>Demo project for Spring Boot</description> <!--Maven屬性配置--> <properties> <java.version>1.8</java.version> </properties> <dependencies> <!--SpringBoot框架開發web項目的起步依賴--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--SpringBoot框架的起步測試依賴--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- springboot 開發自動熱部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <!--SpringBoot的打包編譯插件--> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
具體配置內容可參考: https://www.cnblogs.com/shenlailai/p/10462828.html (IDEA插件創建)
