开发者

Error when adding Jar to Maven project

开发者 https://www.devze.com 2022-12-22 07:31 出处:网络
I\'ve added a jar to the \'Referenced Librarie开发者_开发百科s\' section in Eclipse, which now allows me to see objects from this jar when coding. However when I build with maven, I keep getting The i

I've added a jar to the 'Referenced Librarie开发者_开发百科s' section in Eclipse, which now allows me to see objects from this jar when coding. However when I build with maven, I keep getting The import ____ cannot be resolved errors.

How do I fix this? Do I have to add in the pom.xml? I'm trying use smartgwt.jar.

Also - What would be the 'proper' way to do it?


As the other answer suggests, you should use eclipse or maven. Maven has a useful eclipse:eclipse target that can be used to generate an eclipse project that can be imported in eclipse.

I found this example on http://code.google.com/p/smartgwt/issues/detail?id=12 Should be worth a try.

Basically, update your pom.xml with

<pluginRepositories>
    <pluginRepository>
        <id>gwt-maven-plugins</id>
        <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
    </pluginRepository>
</pluginRepositories>    
<repositories>        
    <repository>
        <id>gwt-maven</id>
        <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
    </repository>
    <repository>
        <id>smartclient</id>
        <name>smartclient.com</name>
        <url>http://www.smartclient.com/maven2</url>
   </repository>
</repositories>

And add the dependency:

<dependency>
    <groupId>com.smartgwt</groupId>
    <artifactId>smartgwt</artifactId>
    <version>2.0</version>
</dependency>


Maven doesn't have any knowledge of things that are not declared in the pom.xml so, yes, you have to declare smartgwt in the POM. Actually, the common way to work with Maven and IDEs is to add things in the POM and to generate or derive things at the IDE level from the POM. In the case of Eclipse, this can be done using the maven-eclipse-plugin or M2Eclipse (the later would be my recommendation here and supports bi-directional actions).

Having all that said, the fact is that smartgwt isn't distributed in Maven central repository so you'll have to add its repository (where to find it) and the dependency.

<project>
  ...
  <repositories>
    <repository>
      <id>SmartGWT</id>
      <url>http://www.smartclient.com/maven2</url>
    </repository>
  </repositories>
  ...
  <dependencies>
    <dependency>
      <groupId>com.smartgwt</groupId>
      <artifactId>smartgwt</artifactId>
      <version>2.1</version><!-- or whatever version you're using -->
    </dependency>
    ...
  </dependencies>
</project>

The smartgwt project somehow provides some (outdated) documentation in HowToEclipseGWTMaven.


You should manage your dependencies either through Eclipse OR through maven. Maven has a nice utility to create Eclipse project files, and there's a plugin to manage the pom file in Eclipse.

To specifically solve you problem, you need to find the artifactId and groupId (and possibly the version as well) for the jar you want. Then add this to the pom file. Then maven will build correctly.

0

精彩评论

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