更新build.gradle从类路径中删除库

时间:2018-11-07 13:35:47

标签: java spring-mvc

我用gradle创建了spring mvc项目,但是我遇到了以下问题。

我知道解决此问题的方法很简单,但我尚未找到它。

这是HibernateConfiguration.java中的代码:

enter image description here

这是build.gradle文件:

plugins {
    id 'java'
    id 'war'
}

group 'com.gtu.gtesting'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
    testCompile group: 'junit', name: 'junit', version: '4.12'

    //---
    testCompile group: 'org.springframework', name:'spring-core', version:'5.1.2.RELEASE'
    testCompile group: 'org.springframework', name:'spring-tx', version:'5.1.2.RELEASE'
    testCompile group: 'org.springframework', name:'spring-beans', version:'5.1.2.RELEASE'
    testCompile group: 'org.springframework', name:'spring-orm', version:'5.1.2.RELEASE'
    testCompile group: 'org.springframework', name: 'spring-mvc', version: '5.1.2.RELEASE'
    testCompile group: 'org.springframework', name: 'spring-webmvc', version: '5.1.2.RELEASE'
    testCompile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.7.Final'
    testCompile group: 'mysql', name: 'mysql-connector-java', version: '8.0.13'
    testCompile group: 'javax.servlet', name: 'jstl', version: '4.0.1'
    testCompile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
    testCompile group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
    testCompile group: 'javax.persistence', name: 'persistence-api', version: '1.0.2'
    testCompile group: 'javax.servlet', name: 'servlet-api', version: '3.0-alpha-1'
}

在我更新build.gradle文件之后(例如,在添加/删除依赖项之后):

每个文件中都有未解析的符号

enter image description here

1 个答案:

答案 0 :(得分:1)

testCompile group组更改为compile group