문제

I have a project that uses ejb and jpa. The build file is as follows:

apply plugin: 'java'
apply plugin:'application'
mainClassName = "com.example.Main"

project.buildDir = 'target'
version = '0.1'

jar{
    destinationDir=project.buildDir
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.glassfish:javax.ejb:3.0.1','org.eclipse.persistence:javax.persistence:2.0.0'
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

When I "gradle clean compileJava" the project, I get these errors:

/home/user/Dropbox/project/src/main/java/com/example/TestClient.java:6: error: package javax.persistence does not exist
import javax.persistence.NamedQuery;
                        ^
/home/user/Dropbox/project/src/main/java/com/example/TestCounter.java:9: error: cannot find symbol
@Entity
 ^
  symbol: class Entity
/home/user/Dropbox/project/src/main/java/com/example/TestCounter:10: error: cannot find symbol
@NamedQuery(name = "findclient", query = "SELECT c FROM TestCounter c")
 ^

However, with the same set of dependencies, I can compile the project in maven. There must be something wrong on the dependency declaration. Spent some time on reading the gradle website, they got a lot of "bla bla" sales pitch but not much on a real thing with some examples.

도움이 되었습니까?

해결책

I have been trying to get it working, and therefore forgot to change the dependencies from runtime to compile as Oli mentioned. So, if anybody runs into this problem, I'll leave this question.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top