spring - 如何从Java EE容器(JBoss)解决依赖关系

标签 spring maven jakarta-ee gradle

我不熟悉构建工具,现在使用Spring 4.0.6和Gradle开发Web应用程序。

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

package javax.persistence does not exist package javax.servlet does not exist



如何告诉Gradle从容器中解析Java EE依赖关系?我不想在我的项目中添加依赖项,然后在WAR文件中 bundle 了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)

  • 谢谢

    查尔斯

    最佳答案

    我的印象是您应该使用provideCompile将它们排除在 war 之外。

    请参阅: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

    关于spring - 如何从Java EE容器(JBoss)解决依赖关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25977502/

    相关文章:

    java - 访问 dropwizard oauth Web 服务时出现错误 "Credentials are required"

    java - 如何按特定顺序运行 Maven 测试?

    java - Jenkins 执行 Maven 时使用了错误的 Java 版本

    java - 您如何决定在哪些实体类中放置 JPA NamedQuery 注释?

    jakarta-ee - WFLYEJB0043 : A previous execution of timer [timer] is still in progress, 在 [时间] 跳过这个重叠的计划执行

    Spring无法创建数据源bean

    java - 为什么AutowiredAnnotationBeanPostProcessor支持@Value?

    java - 如何在没有 Activity FacesContext 的情况下生成 ELContext?

    java - 我可以在spring服务层使用静态变量吗?

    spring - jOOQ 3.1 打印日志,但 jOOQ 3.4 不打印