开发者

Maven - how to put the build dependance jar files?

开发者 https://www.devze.com 2022-12-31 08:39 出处:网络
I run a simple CXF maven project http://cxf.apache.org/docs/using-cxf-with-maven.html, and get error below

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


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.


You have to define it in the pom.xml

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


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).


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

0

精彩评论

暂无评论...
验证码 换一张
取 消