我正在关注Hibernate documentation并试图在我的日食中创建一个Maven项目。我已经根据Hibernate文档中显示的groupId, artifactId and version
中的信息,选择了eclipse中显示的默认选项,除了我选择的org.hibernate.tutorials, hibernate-tutorial, 1.0.0-SNAPSHOT
详细信息(pom.xml
之外),我创建了一个新的maven项目。之后,我用文档中显示的文件替换了项目中的pom.xml
文件。然后我添加了文档中缺少的每个依赖项的版本详细信息。这是我的最终pom.xml
文件:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hibernate.tutorials</groupId>
<artifactId>hibernate-tutorial</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>First Hibernate Tutorial</name>
<build>
<!-- we dont want the version to be part of the generated war file name -->
<finalName>${artifactId}</finalName>
</build>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<!-- Because this is a web app, we also have a dependency on the servlet api. -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<!-- Hibernate uses slf4j for logging, for our purposes here use the simple backend -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
</dependencies>
现在在eclipse中我看到以下错误:
1) Maven Configuration Problem:
Failure to transfer
org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from
http://repo.maven.apache.org/maven2 was cached in the local
repository, resolution will not be reattempted until the update
interval of central has elapsed or updates are forced. Original error:
Could not transfer artifact
org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to
central (http://repo.maven.apache.org/maven2): The operation was
cancelled.
2) Maven Problems:
CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 (): ArtifactDescriptorException: Failed to read artifact descriptor for org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1: UnresolvableModelException: Failure to transfer org.codehaus.plexus:plexus-containers:pom:1.0.3 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.plexus:plexus-containers:pom:1.0.3 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled.
3) Maven Problem:
CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be resolved: Failure to transfer org.codehaus.plexus:plexus-utils:jar:1.4.1 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.plexus:plexus-utils:jar:1.4.1 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled.
4) Maven Problem:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (execution: default-compile, phase: compile)
5) Maven Problem:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (execution: default-testCompile, phase: test-compile)
6) Maven Problem:
Project configuration is not up-to-date with pom.xml. Run Maven->Update Project or use Quick Fix.
更新:当我在eclipse中构建项目时,我收到以下错误:
Errors occurred during the build.
Errors running builder 'Maven Project Builder' on project 'hibernate-tutorial'.
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5
请帮助我如何解决这些问题。我在学习Hibernate的第一步就被阻止了。
提前致谢。
答案 0 :(得分:4)
退出日食
删除(或重命名为安全)您的.m2 / repository目录,它将位于您计算机上的home directory。
启动eclipse,右键单击您的项目,选择Update Maven Project,选中Force Update of Snapshots / Releases,按OK
答案 1 :(得分:0)
它不允许我重命名.m2目录。以下是解决我的错误的详细步骤: *我从Eclipse中删除了项目 *退出Eclipse *从C / Users / Kshitija /位置删除(未移位删除).m2文件夹 *打开Eclipse,再次创建maven项目 *右键点击项目 - &gt; Maven - &gt;更新项目 - &gt;选择&#34;选中强制更新快照/版本&#34;,然后按确定 一旦项目建成,错误就消失了