首先說下原因,根據(jù)官網(wǎng)所說,以后jdk版本主流為17,而且在2023年11月24日,3.0以下的版本不再支持了,升級(jí)為17后大部分用戶需要修改import相關(guān)API的時(shí)候,要用jakarta替換javax。比如:原來引入javax.servlet.Filter的地方,需要替換為jakarta.servlet.Filter
再說解決辦法,網(wǎng)上查到的解決辦法有兩種,一種是創(chuàng)建SpringBoot時(shí),把https://start.spring.io/
或者http://start.springboot.io/
替換為?https://start.aliyun.com/
這個(gè)我試了一下,發(fā)現(xiàn)報(bào)錯(cuò),就沒在深入試了
第二個(gè)辦法就是升級(jí)到17。
最后我試了下創(chuàng)建SpringBoot項(xiàng)目時(shí)就使用17創(chuàng)建,創(chuàng)建完后進(jìn)入pom文件,修改版本
號(hào),我的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 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.17</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.testvesion</groupId>
<artifactId>testvesion</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>testvesion</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.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
之后就可以運(yùn)行了。文章來源:http://www.zghlxwxcb.cn/news/detail-762584.html
大家如果有別的解決辦法,希望評(píng)論區(qū)留下解決辦法文章來源地址http://www.zghlxwxcb.cn/news/detail-762584.html
到了這里,關(guān)于idea創(chuàng)建spring boot項(xiàng)目時(shí)javaversion只能選擇17和21的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!