我正在使用带有spring和hibernate的maven创建一个项目。我在pom.xml中添加了使用javax.persistence包的依赖项,如
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>1.0.2.GA</version>
</dependency>
添加此依赖项后尝试导入包javax.persistence但它没有显示出来。然后我从与之相关的mvnrepository下载了jar文件,然后显然能够导入包。我想,Maven处理依赖,并且不应该有任何下载jar然后将其添加到构建路径的必要性。
有人可以解释我哪里出错吗?
.project文件具有以下内容:
<projectDescription>
<name>SampleWebApp</name>
<comment>This is the sample web app. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
<projects/>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
答案 0 :(得分:0)
在pom所在的目录中执行此命令:
mvn eclipse:clean eclipse:eclipse
然后刷新项目(右键单击项目&gt;刷新)
mvn eclipse:eclispe
构建目标创建一个.project
文件,其中包含更正的构建路径条目
答案 1 :(得分:0)
我不知道问题是什么,但在删除项目并创建另一个archetype设置为spring后,它成功运行。我确实读过与m2eclipse和maven-eclipse-plugin存在一些冲突。现在,问题似乎已经解决了。