【问题标题】:Maven dependencies not resolved in EclipseEclipse 中未解决的 Maven 依赖项
【发布时间】:2017-06-25 14:49:22
【问题描述】:

我正在使用 maven 依赖项开发 Oracle 自定义身份验证插件 (OAM 11g)。我已按照 Oracle 文档中列出的所有步骤添加 maven 依赖项:

1) 使用 OTN 创建帐户并接受许可 2)创建我的设置文件和POM文件并添加以下内容:

<server>
    <id>maven.oracle.com</id>
      <username>myemail@gmail.com</username>
        <password>*******</password>
          <configuration>
           <basicAuthScope>
           <host>ANY</host>
           <port>ANY</port>
           <realm>OAM 11g</realm>
      </basicAuthScope>
      <httpConfiguration>
          <all>
          <params>
          <property>
          <name>http.protocol.allow-circular-redirects</name>
          <value>%b,true</value>
          </property>
          </params>
        </all>
      </httpConfiguration>
    </configuration>
  </server>

执行这些步骤后,我的 Java 类中仍然出现错误“无法解析导入 oracle.security”,这意味着依赖项并没有在我的程序中解析。如果有人可以帮助我理解这个问题,我将不胜感激。谢谢

【问题讨论】:

    标签: oracle maven oracle11g oam


    【解决方案1】:

    您需要将以下存储库定义添加到您的 pom.xml。

    您可以在此处获得更多信息设置multiple repositories

    <repositories>
      <repository>
        <id>maven.oracle.com</id>
        <releases>
          <enabled>true</enabled>
        </releases>
        <snapshots>
          <enabled>false</enabled>
        </snapshots>
        <url>https://maven.oracle.com</url>
        <layout>default</layout>
      </repository>
    </repositories>
    <pluginRepositories>
      <pluginRepository>
        <id>maven.oracle.com</id>
        <url>https://maven.oracle.com</url>
      </pluginRepository>
    </pluginRepositories>
    

    【讨论】:

    • 我已经在 pom 文件和 settings.xml 中有这个,但我仍然得到这个错误。还有什么我需要的吗?..谢谢
    【解决方案2】:

    我认为这个问题与 Oracle 安全性无关。由于许可限制,与 oracle 相关的罐子通常不会发布到 maven Central。你需要

    1. 手动将 jar 上传到您的公司 nexus 或 artifactory。
    2. 或将它们与您的项目一起保存并使用system dependency 机制。

    第 2 点解释:

    1. 在您的项目中维护一个 jar 文件夹并将 jar 文件保存在那里。
    2. 在 pom 中的依赖项 sn-p 中,
    <dependencies>
        <dependency>
          <groupId>oracle.security</groupId>
          <artifactId>oracle-api</artifactId>
          <version>2.0</version>
          <scope>system</scope>
          <systemPath>${project.basedir}/jars/oracle-api.jar</systemPath>
        </dependency>
     </dependencies>
    

    对其他罐子也重复上述操作。

    这将解决您的 The import oracle.security cannot be resolved 异常。

    【讨论】:

    • 嗨@GauravJ,您能否向我解释一下如何实现您上面提到的第二个选项。感谢您抽出宝贵时间提供帮助。
    • 我已经修改了答案
    • 嗨@GauravJ,感谢您抽出宝贵时间来解释这第二步。让我在这里尝试这种新方法,看看是否有帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-16
    • 1970-01-01
    • 2012-12-12
    • 1970-01-01
    • 2012-01-12
    • 1970-01-01
    相关资源
    最近更新 更多