有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JavaGradle没有看到Spring包,但是声明了一个依赖项

我正在做我的新项目。但当我尝试构建它时,gradle返回错误:

 error: package org.springramework.transaction does not exist
import org.springframework.transaction.PlatformTransactionManager;

error: package org.springramework.orm.hibernate5 does not exist
import org.springframework.orm.hibernate5.HibernateTransactionManager;

这是我的身材。格拉德尔:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.bmuschko:gradle-tomcat-plugin:2.4.1'
    }
}

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat'

compileJava.options.encoding = 'UTF-8'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

def tomcatVersion = '9.0.22'
dependencies {
    testImplementation 'junit:junit:4.12'
    tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
            "org.apache.tomcat.embed:tomcat-embed-logging-juli:8.5.2",
            "org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion},"

    testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
    testCompile group: 'org.mockito', name: 'mockito-all', version: '1.8.4'
}

tomcat {
    httpProtocol = 'org.apache.coyote.http11.Http11Nio2Protocol'
    ajpProtocol  = 'org.apache.coyote.ajp.AjpNio2Protocol'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.apache.tomcat:tomcat-dbcp:9.0.22'
    implementation 'org.postgresql:postgresql:42.2.6'
    implementation 'org.springframework:spring-context:5.1.8.RELEASE'
    implementation 'org.springframework:spring-webmvc:5.1.8.RELEASE'
    implementation 'org.springframework:spring-orm:5.1.8.RELEASE'
    implementation 'org.springframework:spring-tx:5.1.8.RELEASE'
    implementation 'org.hibernate:hibernate-core:5.4.1.Final'
}

spring上下文导入没有错误。 我知道,这很奇怪,但在文件夹中 ~/.gradle/caches/modules-2/files-2.1/org.springframeworkspringorm和springtx文件夹都有jar。 我做错了什么


共 (0) 个答案