如何从Java EE容器(JBoss)解析依赖关系

时间:2014-09-22 15:13:29

标签: spring maven java-ee gradle

我是新手来构建工具,现在使用Spring 4.0.6和Gradle开发Web应用程序。

运行 gradle build 时,出现错误,说javax.persistence和javax.servlet无法解析:

  

包javax.persistence不存在   包javax.servlet不存在

如何告诉Gradle从容器中解析Java EE依赖项?我不想在我的项目中添加依赖项,然后在我的WAR文件中捆绑了像hibernate和servlet-api这样的JAR。我想从容器中获取它们,这是Java EE容器的主要目的......

我的 build.gradle 文件:

apply plugin: 'war'

repositories {

    maven {
        url "file://my_internal_maven_repo_server/maven2"
    }
}

dependencies {
    compile 'org.springframework:spring-webmvc:4.0.6.RELEASE'
    compile 'org.springframework.security:spring-security-web:3.2.5.RELEASE'
    compile 'org.springframework.ldap:spring-ldap-core:2.0.2.RELEASE'

    compile 'org.thymeleaf:thymeleaf:2.1.3.RELEASE'
    compile 'org.thymeleaf:thymeleaf-spring4:2.1.3.RELEASE'
}

我的规格:

  • IDE:Eclipse Juno。
  • Java EE容器:JBoss AS 7.2
  • 申请格式:WAR(所需的构建结构here

谢谢

查尔斯

1 个答案:

答案 0 :(得分:1)

我的印象是你应该使用providedCompile将它们排除在战争之外。

请参阅:http://www.gradle.org/docs/current/userguide/war_plugin.html

http://gesellix.net/providedcompile-and-compile-dependencies-with-gradle/

例如:

providedCompile ("org.jboss.jbossas:jboss-as-client:6.0.0.Final")

How do you integrate gradle and jboss 6 to generate working eclipse projects