我正在尝试让这个应用程序工作,并且该建筑是在 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/