سؤال

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