Maven - 如何放置构建依赖 jar 文件?

发布于 2024-09-02 06:18:10 字数 1495 浏览 3 评论 0原文

我运行一个简单的 CXF maven 项目 http://cxf.apache.org /docs/using-cxf-with-maven.html,并在下面出现错误

[INFO] [cxf-codegen:wsdl2java {execution: generate-sources}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------
[INFO] org/springframework/core/io/support/ResourcePatternResolver

org.springframework.core.io.support.ResourcePatternResolver
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: org/springframework/core/io/support/ResourcePatternResolver
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)

我不知道如何放置 springframework-core 依赖项?

我像大多数答案一样尝试了下面的方法

       <dependency>
         <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>2.5.6</version>
   </dependency>
</dependencies>

,但没有帮助,我也不知道为什么它依赖于 springframework

如果我将 jar 文件放在 $M2_HOME/lib 下,它就可以工作,但它是正确的方法吗?因为当我解决这个问题时,它需要在那里添加更多的库,我可以将它放入 pom.xml 的某个地方吗?

我尝试将 放入 标记中,但它不起作用,

我的 maven 在 Windows 上是 2.2.1

I run a simple CXF maven project http://cxf.apache.org/docs/using-cxf-with-maven.html, and get error below

[INFO] [cxf-codegen:wsdl2java {execution: generate-sources}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------
[INFO] org/springframework/core/io/support/ResourcePatternResolver

org.springframework.core.io.support.ResourcePatternResolver
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: org/springframework/core/io/support/ResourcePatternResolver
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)

I don't know how to put the springframework-core dependance ?

I tried below like most of answers

       <dependency>
         <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>2.5.6</version>
   </dependency>
</dependencies>

but it didn't help, I also don't know why it depends on springframework

It works if I put the jar file under $M2_HOME/lib, but is it correct way ? since when I solve this, it requires to add more lib there, can I put it into pom.xml somewhere ?

I tried to put <dependencies/> inside <build> tag, it doesn't work

my maven is 2.2.1 on windows

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

合久必婚 2024-09-09 06:18:11

如果我将 jar 文件放在 $M2_HOME/lib 下,它就可以工作,但这是正确的方法吗?

不,绝对不是。要添加依赖项,您需要在 pom.xml 中声明它,如下所示:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>???</version>
    </dependency>
    ...
  </dependencies>
</project>

但我不明白为什么您必须添加此依赖项,spring-core is< /strong> cxf 的依赖项,您应该传递地获取它。不过,您没有提供足够的上下文信息来获得更准确的答案。

It works if I put the jar file under $M2_HOME/lib, but is it correct way ?

No, definitely not. To add a dependency, you need to declare it in your pom.xml, something like this:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>???</version>
    </dependency>
    ...
  </dependencies>
</project>

But I don't understand why you would have to add this dependency, spring-core is a dependency of cxf, you should get it transitively. You're not providing enough context information for a more precise answer though.

心如荒岛 2024-09-09 06:18:11

您必须在 pom.xml 中定义它,

请阅读 http://maven.apache 上的文档。 org/pom.html#依赖项

You have to define it in the pom.xml

Read the docs at http://maven.apache.org/pom.html#Dependencies

一场春暖 2024-09-09 06:18:11

您需要将其添加到 Maven pom.xml 文件的 部分:

 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>???</version>
  </dependency>

版本号将取决于您使用的 spring 版本。 (我使用 2.0 作为版本号,以及 spring 2.0.8)。

You'll need to add this to your Maven pom.xml file in the <dependencies> section:

 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>???</version>
  </dependency>

The version number will depend on which version of spring you're using. (I'm using 2.0 as the version #, along with spring 2.0.8).

五里雾 2024-09-09 06:18:11

最后我自己找到了它,这是由于我的本地存储库中的 springframework-2.5.5 包错误所致。 jar 文件不正确。我注意到稍后在 eclipse 中

Pascal 的答案也是正确的。

springframework-2.5.5是由maven自动下载的,不幸的是它被破坏了,所以它仍然抱怨类,如果我把springframework-2.5.6放进去,即使它会被下载,它也不会被使用,maven仍然认为它将 springframework-2.5.5 加载到其类路径中。

如果我放入%M2_HOME%/lib,肯定会是maven的类路径,并且使用它是错误的。

由于我以前遇到过这种问题,现在我知道这是什么问题了。

摘要:检查您的依赖文件以查看包是否正确

顺便说一句:感谢大家,尤其是 pascal

Finally I found it by myself, it is due to the error of my springframework-2.5.5 package from local repository. The jar file is not correct. I notice this later in eclipse

Pascal's answer is also correct.

The springframework-2.5.5 is automatically download by maven, unfortunately it is broken, so it still complain the class, and if I put springframework-2.5.6 inside, even it will be downloaded, it will not be used, maven still think it loaded the springframework-2.5.5 into its classpath.

And if I put into %M2_HOME%/lib, surely it will be maven's classpath, and it is wrong to use it.

Since I met this kind of problem before, now I know what it is.

Summary: checking your dependance files to see whether the package is correct

BTW: Thanks for all especially pascal

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文