Lak*_*ani 28 java spring maven spring-boot
我是 Spring Boot 的新手,我打算将 h2 数据库与 maven 项目连接起来。这是我的 pom.Xml 文件。该文件给出了错误插件 'org.springframework.boot:spring-boot-maven-plugin:' not found
<?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.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>dev.che</groupId>
<artifactId>stu</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>stu</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-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?
Wag*_*ues 80
解决了在pom.xml中添加插件版本的问题,与spring boot的版本一致。
所以你只需要像这样配置你的pom:
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
Run Code Online (Sandbox Code Playgroud)
Sal*_*dji 15
我解决了在 pom.xml 中添加插件版本的问题
<version>2.4.3</version>Run Code Online (Sandbox Code Playgroud)
小智 8
我通过添加版本解决了这个问题:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
该pom.xml的是正确的。好像是网络问题。因此没有下载插件。
解决问题的步骤:
检查网络问题。您需要有强大的互联网连接才能使用 maven 下载所有依赖项和插件。否则,您肯定会遇到构建 maven 项目的问题。
对于日食/STS:
右键单击项目>> Run As >> Maven clean(这将通过删除目标文件夹来清理项目)。
例子 :
例子 :
注意:启用选项强制更新快照/发布(查看上面的屏幕截图)。默认情况下,此选项未启用。单击确定。它将开始更新。
在这里下载 maven并解压。
在环境变量上设置 maven 位置,以便它可以从任何地方运行。
打开 CMD/Terminal 然后mvn clean install在项目里面做。
查看者更新: <version>标签不是 spring-boot 项目的强制性标签,因为spring 为 spring-boot 创建的pom.xml可以处理spring-boot-maven-plugin.
更新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 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.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>dev.che</groupId>
<artifactId>stu</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>stu</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-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
编辑 :
如果上述步骤没有解决您的问题,那么您可以通过在pluginfor spring-boot-maven-plugin(不是推荐的解决方案)中明确提供父 Spring Boot 版本来寻求变通解决方案:
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${parent.version}</version>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)
小智 7
我在2022年1月版本更改为2.6.3时遇到了这个问题。我也将项目的版本降低到2.6.2,但没有成功。<version>${project.parent.version}</version>但是,无论版本如何,添加以下行插件都可以解决问题。下面给出了片段
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45850 次 |
| 最近记录: |