Intellij Idea创建SpringBoot时无法连接https://start.spring.io

本文提供了解决在创建SpringBoot项目时遇到特定错误的方法。通过搭建本地服务并使用initializr-service工具,绕过网络代理限制,成功在IntelliJ IDEA中配置并创建项目。

错误如下:

创建springboot项目时,提示如下错误信息

解决方案:

搭建本地服务:https://start.spring.io/

  • 下载initializr-service-0.5.0.BUILD-SNAPSHOT.jar
  • 本地启动服务:java -jar initializr-service-0.5.0.BUILD-SNAPSHOT.jar --server.port=9099

Intellij Idea配置:

选择File -> settings -> HTTP Proxy -> Auto-detect proxy settings:

URL设置为本地服务地址:http://127.0.0.1:9099

使用 IntelliJ IDEA 创建 Spring Boot 项目,若要将默认的 `https://start.spring.io` 替换为阿里的 Spring 项目初始化服务,可以按照以下步骤操作: #### 操作步骤 1. **打开项目创建向导**:在 IDEA 中,选择 `File` -> `New` -> `Project`,在左侧选择 `Spring Initializr`。 2. **修改服务 URL**:在右侧的 `Service URL` 字段中,将默认的 `https://start.spring.io` 替换为阿里的 Spring 项目初始化服务地址 `https://start.aliyun.com`。 3. **完成项目创建**:按照向导的提示,设置项目的其他信息,如项目名称、包名、依赖等,最后点击 `Create` 完成项目创建。 #### 代码示例 虽然创建项目过程中一般不需要编写代码,但可以查看生成项目的配置文件 `pom.xml`(如果是 Maven 项目)或 `build.gradle`(如果是 Gradle 项目),确认项目的依赖和配置是否正确。 **Maven 项目的 `pom.xml` 示例**: ```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 https://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.7.5</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.example</groupId> <artifactId>demo</artifactId> <version>0.0.1-SNAPSHOT</version> <name>demo</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <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> ``` **Gradle 项目的 `build.gradle` 示例**: ```groovy plugins { id 'org.springframework.boot' version '2.7.5' id 'io.spring.dependency-management' version '1.0.15.RELEASE' id 'java' } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '1.8' repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' testImplementation 'org.springframework.boot:spring-boot-starter-test' } test { useJUnitPlatform() } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值