I created a new maven project using the following maven command
我使用以下maven命令创建了一个新的maven项目
mvn archetype:generate -DgroupId=com.company.lib_name -DartifactId=lib_name -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
When I open this newly created project in eclipse it gives the following error:
当我在eclipse中打开这个新创建的项目时,会出现以下错误:
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-jar- plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar:2.3.2
Plugin org.apache.maven.plugins:maven-jar-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-jar-plugin:jar:2.3.2: Hostname cannot be null
I tried th following:
我试过以下:
- Deleted the .m2/repository and rebuilt the project
- Verified that the artifact exists in the maven repo
- Maven user settings point to the correct settings.xml
- Project compiles on the command line
- Cleaned the project
- Forced updates n the project
- Checked repo to see all the dependencies are downloaded
- Change eclipse to use the external maven instead of embeded Also I am using Kepler and Maven 3.
删除.m2 / repository并重建项目
已验证该工件存在于maven仓库中
Maven用户设置指向正确的settings.xml
项目在命令行上编译
清理了这个项目
强制更新项目
检查repo以查看所有依赖项已下载
改变eclipse使用外部maven而不是embeded我也使用Kepler和Maven 3。
Any idea what 'hostname cannot be null' is pointing at?
知道什么'主机名不能为空'指的是什么?
THis is the pom content
这是pom的内容
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.lib</groupId>
<artifactId>liby</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>lib</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
</dependencies>
</project>
And the settings.xml
和settings.xml
<settings>
<profiles>
<profile>
<id>Blah</id>
<repositories>
<repository>
<id>inhouse</id>
<url>http://mavenrepo/maven2_repositories/inhouse</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>inhouse_snapshot</id>
<url>http://mavenrepo/maven2_repositories/inhouse_snapshot</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>inhouse</id>
<url>http://mavenrepo/maven2_repositories/inhouse</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>inhouse_snapshot</id>
<url>http://mavenrepo/maven2_repositories/inhouse_snapshot</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>company_name</activeProfile>
</activeProfiles>
<mirrors>
<mirror>
<id>central-to-nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://mw_maven_repository_readonly/nexus/content/groups/cached</url>
</mirror>
</mirrors>
3 个解决方案
#1
It seems that you have created the project from Maven Template but you did not make this project as an Eclipse project before import it in Eclipse.
您似乎已经从Maven模板创建了项目,但在Eclipse中导入之前您没有将此项目作为Eclipse项目。
So after create a new maven project using the maven command you should also execute the below command to make the project as an Eclipse project
因此,在使用maven命令创建新的maven项目之后,您还应该执行以下命令以将项目作为Eclipse项目
mvn eclipse:eclipse
It will generate all project files that are required by Eclipse IDE.
它将生成Eclipse IDE所需的所有项目文件。
I also prefer to execute "mvn clean install" before import the project in Eclipse.
我还喜欢在Eclipse中导入项目之前执行“mvn clean install”。
#2
At command prompt :
在命令提示符下:
mvn eclipse:eclipse
mvn clean install
mvn eclipse:eclipse mvn clean install
This should download all dependencies
这应该下载所有依赖项
#3
Thank you all for the answers. but the problem was with the maven repo url.
谢谢大家的答案。但问题出在maven repo网址上。
#1
It seems that you have created the project from Maven Template but you did not make this project as an Eclipse project before import it in Eclipse.
您似乎已经从Maven模板创建了项目,但在Eclipse中导入之前您没有将此项目作为Eclipse项目。
So after create a new maven project using the maven command you should also execute the below command to make the project as an Eclipse project
因此,在使用maven命令创建新的maven项目之后,您还应该执行以下命令以将项目作为Eclipse项目
mvn eclipse:eclipse
It will generate all project files that are required by Eclipse IDE.
它将生成Eclipse IDE所需的所有项目文件。
I also prefer to execute "mvn clean install" before import the project in Eclipse.
我还喜欢在Eclipse中导入项目之前执行“mvn clean install”。
#2
At command prompt :
在命令提示符下:
mvn eclipse:eclipse
mvn clean install
mvn eclipse:eclipse mvn clean install
This should download all dependencies
这应该下载所有依赖项
#3
Thank you all for the answers. but the problem was with the maven repo url.
谢谢大家的答案。但问题出在maven repo网址上。