gpt4 book ai didi

java - gretty appStart 失败,属性未知 'classesDirs'

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:10:25 25 4
gpt4 key购买 nike

我正在尝试使用 gradle gretty 插件(gradle 版本 3.4)构建 Java Servlet。我依赖于另一个项目 databaseprovider:1.0-SNAPSHOT(包括与数据库的连接和一些 spring 定义......)。当我运行任务“gradle war”时,.war 文件已正确构建,并包含 WEB-INF/lib 中的所有依赖项。但是当我尝试从“gradle appStart”开始时,我遇到了以下问题:

What went wrong: Execution failed for task ':appStart'. Could not get unknown property 'classesDirs' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'classesDirs' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.

没有依赖 databaseprovider:1.0-SNAPSHOT jetty 启动没有问题:

INFO Jetty 9.2.22.v20170606 started and listening on port 8080

build.gradle:

buildscript {
repositories {
jcenter()
}

dependencies {
classpath "org.akhikhl.gretty:gretty:+"
classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE"
}
}

apply plugin:'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply from: 'https://raw.github.com/akhikhl/gretty/master/pluginScripts/gretty.plugin'

repositories {
maven {
url "http://..."
}
mavenLocal()
}

dependencies {
compile('databaseprovider:1.0-SNAPSHOT'){
changing=true
}
}

gretty {
httpPort = 8080
contextPath = '/'
servletContainer = 'jetty9'
}

来自数据库提供者的build.gradle:

buildscript {
repositories {
maven {
url "http://..."
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply from: 'liquibase.gradle'


jar {
baseName = 'databaseprovider'
version = '1.0-SNAPSHOT'
}

repositories {
maven {
url "http://..."
}
mavenLocal()
jcenter()
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile("org.springframework.boot:spring-boot-starter-data-jpa:1.4.0.RELEASE")
compile group: 'org.springframework.data', name: 'spring-data-jpa', version:'1.10.2.RELEASE'
compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '5.0.9.Final'
testRuntime group: 'com.h2database', name: 'h2', version: '1.4.192'
compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.0.13'
compile group: 'ch.qos.logback', name: 'logback-core', version:'1.0.13'
compile group: 'org.slf4j', name: 'slf4j-api', version:'1.7.5'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version:'1.7.5'
compile group: 'org.slf4j', name: 'log4j-over-slf4j', version:'1.7.5'
compile group: 'org.reflections', name: 'reflections', version: '0.9.11'
compile (group: 'com.mattbertolini', name: 'liquibase-slf4j', version: "1.2.1")
compile (group: 'org.liquibase', name: 'liquibase-core', version: "3.5.3")
compile group: 'javax.validation', name: 'validation-api', version: '1.1.0.Final'
testCompile("junit:junit")
runtime("mysql:mysql-connector-java:5.1.39")
testCompile("org.springframework:spring-test")
}

最佳答案

我能够通过添加 gretty 的版本来解决问题:

在我改变build.gradle中的类路径之后

classpath "org.akhikhl.gretty:gretty:+"

classpath "org.akhikhl.gretty:gretty:1.4.2"

(与 gradle 3.4 兼容的版本)jetty 无异常启动。

关于java - gretty appStart 失败,属性未知 'classesDirs',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46321449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com