英文:
Why isn't IntelliJ IDEA resolving maven properties?
问题
我正在运行 Windows 10 64 位操作系统上的 IntelliJ IDEA 2019.3 社区版。它已正确导入和解析了一些依赖项,如 spring-boot、MySQL 连接器 Java 等等。然而,当我尝试添加新的 hibernate-core 依赖并导入更改时,它显示 "无法解析依赖项 hibernate core"。
以下是您提供的 "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.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.resondate</groupId>
<artifactId>resondate</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>resondate</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-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 其他依赖项已省略 -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Alpha4</version>
<type>pom</type>
</dependency>
</dependencies>
<!-- 其他部分已省略 -->
</project>
出现的错误消息如下:
无法解析 org.hibernate:hibernate-core:6.0.0.Alpha4
对于所有版本的 hibernate-core 都出现了此错误。请提供关于为何会发生这种情况的见解。谢谢。
英文:
I'm running IntelliJ IDEA 2019.3 community edition on windows 10 64-bit. It correctly imported and resolved few dependencies like spring-boot, MySQL connector Java, etc.,. However, when I try to add a new dependency for hibernate-core and import changes, it says "Cannot resolve dependency hibernate core".
The "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.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.resondate</groupId>
<artifactId>resondate</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>resondate</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-security</artifactId>
</dependency>
<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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.0</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.8.4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.14</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Alpha4</version>
<type>pom</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The error message that comes up is as follows:
> Cannot resolve org.hibernate:hibernate-core:6.0.0.Alpha4
It does this for all versions of hibernate-core. Please provide insights as to why this is happening. Thank you.
答案1
得分: 0
- 不要使用 Hibernate 的 Alpha 版本。
- 如果你无法抵制,而不是覆盖整个依赖块,只需指定你想要的版本。多亏了 Spring Boot 的父 POM,这将无缝地运行。示例:
而不是:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Alpha4</version>
<type>pom</type>
</dependency>
做:
<properties>
<hibernate.version>5.4.13.Final</hibernate.version>
</properties>
对于所有其他依赖也是如此,比如 mysql 等。
3. 将版本覆盖为 6.0.0.Alpha 对于 Hibernate 来说不起作用,因为实际的 groupId 已经更改为 org.hibernate.orm
。因此,我不会这样做 :)。
英文:
- Don't use Hibernate's Alpha version.
- If you cannot resist, instead of overriding the whole dependency block, just specify the version you want. Thanks to Spring Boot's parent pom this will work flawlessly. Example:
Instead of:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.0.0.Alpha4</version>
<type>pom</type>
</dependency>
Do:
<properties>
<hibernate.version>5.4.13.Final</hibernate.version>
</properties>
Same for all other dependencies, like mysql etc.
- The version override to 6.0.0.Alpha won't work for Hibernate, as the actual groupId has changed, to
org.hibernate.orm
. Hence, I wouldn't do it
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论