找不到java Gradle[METAINF/persistence.xml]
我正在使用gradle
构建我的JPA
/EJB
项目,并收到以下警告:
$ gradle jar
:compileJava
Note: Creating static metadata factory ...
Note: The persistence xml file [META-INF/persistence.xml] was not found. NO GENERATION will occur!! Please ensure a persistence xml file is available either from the CLASS_OUTPUT directory [META-INF/persistence.xml] or using the eclipselink.persistencexml property to specify its location.
2 warnings
:processResources UP-TO-DATE
:classes
:jar
我的项目结构:
ProjectX
|-src
|---main
|-----java
|-------domain
|-------ejb
|-----resources
|-------META-INF
|-----------persistence.xml
有趣的是,坚持。xml最终会出现在目标jar工件中:
$ jar -tf target/projectx.jar
META-INF/
META-INF/MANIFEST.MF
domain/
domain/Employee.class
ejb/
ejb/EmployeeEJB.class
META-INF/persistence.xml
为什么有人抱怨[META-INF/persistence.xml]
即使它在那里
gradle文件:
apply plugin: 'java'
project.buildDir = 'target'
sourceSets.all {
output.resourcesDir = output.classesDir
}
jar{
destinationDir=project.buildDir
}
repositories {
mavenCentral()
}
dependencies {
compile 'org.glassfish:javax.ejb:3.0.1','org.eclipse.persistence:javax.persistence:2.0.0'
}
我现在已经很快用maven进行了测试,没有这样的警告
# 1 楼答案
坚持。xml应该在src/main/resources/META-INF中。这对我很有用。请不要说这是一个非spring项目