java - Gradle jettyRuns 可以工作,但 Eclipse 中没有依赖项

标签 java eclipse spring hibernate gradle

我正在尝试让这个应用程序工作,并且该建筑是在 gradle 中配置的。当我在 cmd 中使用 jettyRun 来运行应用程序时,它按预期工作,但是当我在 eclipse 中打开实际代码时,我缺少所有这些依赖项,例如 spring 或 hibernate 等...我不确定如何解决此问题

gradle.build 看起来像这样

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
apply plugin: 'jetty'

// JDK 7
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenLocal()
    mavenCentral()
}


dependencies {

     compile 'ch.qos.logback:logback-classic:1.1.3'
     compile 'org.springframework:spring-webmvc:4.1.6.RELEASE'
     compile 'javax.servlet:jstl:1.2'
     compile 'org.springframework:spring-orm:4.1.6.RELEASE'
     compile 'org.springframework:spring-tx:4.1.6.RELEASE'
     compile 'org.springframework:spring-jdbc:4.1.6.RELEASE'
     compile 'mysql:mysql-connector-java:5.1.31'
     compile 'org.hibernate:hibernate-core:4.3.10.Final'
     compile 'org.hibernate:hibernate-entitymanager:4.3.10.Final'   
}

// Embeded Jetty for testing
jettyRun{
    contextPath = "etnshop"
    httpPort = 8080
}

jettyRunWar{
    contextPath = "etnshop"
    httpPort = 8080
}

//For Eclipse IDE only
eclipse {

  wtp {
    component {

      //define context path, default to project folder name
      contextPath = 'etnshop'

    }

  }
}

最佳答案

使用命令gradle eclipse解决了问题。

关于java - Gradle jettyRuns 可以工作,但 Eclipse 中没有依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31467446/

相关文章:

java - Spring Security ACL - @PreAuthorize 泛型和接口(interface)

java - pom.xml 中 ${project.basedir} 的含义

Java:与 GUI 并行启动控制台?

java - 在抽象类中调用重写的函数

java - 当我在 Eclipse 中创建新项目时,为什么 SVN Checkout 不适合我?

eclipse - 禁用 Flex 运行时绑定(bind)警告

java - 如何从 RestTemplate postForLocation 获取 STRING 响应?

java - 如何使用 DiscriminatorValue 保存实体

java - Spring JdbcTemplate 实现审计列的 @PrePersist 和 @PreUpdate

java.io.FileNotFoundException : content://com. android.contacts/contacts/24093/photo 仅适用于旧照片