简体   繁体   English

修复 IntelliJ 中损坏的 Maven 依赖项

[英]Fix Broken Maven Dependencies in IntelliJ

I copied my project with full dependencies and added all modules into IntelliJ, but now maven does not recognize some of the dependencies.我复制了具有完整依赖项的项目并将所有模块添加到 IntelliJ,但现在 maven 无法识别某些依赖项。

When I validate or install dependencies, I see errors like this:当我验证或安装依赖项时,我看到如下错误:

[ERROR] Some problems were encountered while processing the POMs:
'dependencies.dependency.artifactId' for com.oracle:${hibernate.oracle.jdbcDriver.artifactId}:jar with value '${hibernate.oracle.jdbcDriver.artifactId}' does not match a valid id pattern. @ line 170, column 16
'dependencies.dependency.version' for com.oracle:${hibernate.oracle.jdbcDriver.artifactId}:jar must be a valid version but is '${hibernate.oracle.jdbcDriver.version}'. @ line 171, column 13
'dependencies.dependency.version' for com.oracle:orai18n:jar must be a valid version but is '${hibernate.oracle.jdbcDriver.version}'. @ line 176, column 13

在此处输入图像描述

How can I fix this?我怎样才能解决这个问题?

If you post your actual pom xml (if you can) it's better than posting the image but in any case your problem is the versions are not being resolved because they are defined with properties.如果您发布实际的 pom xml (如果可以的话),这比发布图像要好,但无论如何您的问题是版本没有得到解决,因为它们是用属性定义的。

You need to define properties for the missing artifacts in the error, by adding some values inside the <properties> node of your pom.您需要通过在 pom.xml 的<properties>节点内添加一些值来为错误中缺少的工件定义属性。

So basically you need to plug in two values, one for the oracle jdbc artifact id and another for the version.所以基本上你需要插入两个值,一个用于 oracle jdbc 工件 ID,另一个用于版本。

<properties>
  <spring.version>5.1.6.RELEASE</spring.version>
  <hibernate.version>5.4.2.Final</hibernate.version>
  <cxf.version>3.1.16</cxf.version>
  <log4j.version>2.12.1</log4j.version>

  <hibernate.oracle.jdbcDriver.artifactId> version goes here </hibernate.oracle.jdbcDriver.artifactId>
  <hibernate.oracle.jdbcDriver.version> version goes here </hibernate.oracle.jdbcDriver.version>
</properties>

JDBC driver and other companion jars are on central maven. JDBC 驱动程序和其他配套 jars 位于中央 maven。 Why not use the GAV of those directly?为什么不直接使用那些 GAV 呢? The below will download ojdbc8.jar and other companion jars such as orai18n.jar.下面将下载ojdbc8.jar和其他配套jars如orai18n.jar。 Check out maven central guide for more details.查看maven 中央指南了解更多详情。

<dependencies>
  <dependency>
    <groupId>com.oracle.database.jdbc</groupId>
    <artifactId>ojdbc8-production</artifactId>
    <version>21.1.0.0</version>
    <type>pom</type>
  </dependency>
</dependencies> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM