Maven 2 将Jar添加到Maven项目时出错

Maven 2 将Jar添加到Maven项目时出错,maven-2,jar,Maven 2,Jar,我已经在Eclipse中的“引用库”部分添加了一个jar,它现在允许我在编码时查看这个jar中的对象。然而,当我使用maven构建时,我不断得到导入无法解决的错误 我该如何解决这个问题?我是否必须添加pom.xml?我正在尝试使用smartgwt.jar 还有-什么是“正确”的方法呢?您应该通过Eclipse或maven来管理您的依赖关系。Maven有一个很好的工具来创建Eclipse项目文件,并且有一个插件来管理Eclipse中的pom文件 为了具体解决您的问题,您需要找到所需jar的arti

我已经在Eclipse中的“引用库”部分添加了一个jar,它现在允许我在编码时查看这个jar中的对象。然而,当我使用maven构建时,我不断得到导入无法解决的
错误

我该如何解决这个问题?我是否必须添加
pom.xml
?我正在尝试使用
smartgwt.jar


还有-什么是“正确”的方法呢?

您应该通过Eclipse或maven来管理您的依赖关系。Maven有一个很好的工具来创建Eclipse项目文件,并且有一个插件来管理Eclipse中的pom文件


为了具体解决您的问题,您需要找到所需jar的artifactId和groupId(可能还有版本)。然后将其添加到pom文件中。然后maven将正确构建。

您应该通过Eclipse或maven管理您的依赖关系。Maven有一个很好的工具来创建Eclipse项目文件,并且有一个插件来管理Eclipse中的pom文件


为了具体解决您的问题,您需要找到所需jar的artifactId和groupId(可能还有版本)。然后将其添加到pom文件中。然后maven将正确构建。

正如另一个答案所建议的,您应该使用eclipse或maven。Maven有一个有用的
eclipse:eclipse
目标,可用于生成可在eclipse中导入的eclipse项目

我发现这个例子应该值得一试

基本上,使用

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

GWTMaven插件
http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/
gwt马文
http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/
智能客户端
smartclient.com
http://www.smartclient.com/maven2
并添加依赖项:

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

com.smartgwt
smartgwt
2

正如另一个答案所建议的,您应该使用eclipse或maven。Maven有一个有用的
eclipse:eclipse
目标,可用于生成可在eclipse中导入的eclipse项目

我发现这个例子应该值得一试

基本上,使用

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

GWTMaven插件
http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/
gwt马文
http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/
智能客户端
smartclient.com
http://www.smartclient.com/maven2
并添加依赖项:

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

com.smartgwt
smartgwt
2

Maven对未在
pom.xml
中声明的内容一无所知,因此,是的,您必须在pom中声明smartgwt。实际上,使用Maven和IDE的常用方法是在POM中添加内容,并从POM生成或派生IDE级别的内容。在Eclipse的情况下,这可以使用maven Eclipse插件或(我建议使用后者并支持双向操作)来完成

综上所述,事实上smartgwt并不分布在Maven central repository中,因此您必须添加它的存储库(在哪里可以找到它)和依赖项

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

...
SmartGWT
http://www.smartclient.com/maven2
...
com.smartgwt

.

Maven对未在
pom.xml
中声明的内容一无所知,因此,是的,您必须在pom中声明smartgwt。实际上,使用Maven和IDE的常用方法是在POM中添加内容,并从POM生成或派生IDE级别的内容。在Eclipse的情况下,这可以使用maven Eclipse插件或(我建议使用后者并支持双向操作)来完成

综上所述,事实上smartgwt并不分布在Maven central repository中,因此您必须添加它的存储库(在哪里可以找到它)和依赖项

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

...
SmartGWT
http://www.smartclient.com/maven2
...
com.smartgwt

.

@belgarat:指定正确存储库的正确答案:)@belgarat:指定正确存储库的正确答案:)