gpt4 book ai didi

java - 使用 gradle 而不是 eclipse 构建

转载 作者:行者123 更新时间:2023-11-30 07:57:39 24 4
gpt4 key购买 nike

我对整个 tomcat/spring/eclipse 世界都很陌生。
我在 Android 项目中使用了一点 gradle。

这是一个使用 tomcat/spring/eclipse 的项目,我想使用 gradle 构建它。

我从网络上的教程之一复制了 build.gradle 文件。

 buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.5.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

jar {
baseName = 'gs-serving-web-content'
version = '0.1.0'
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
testCompile("junit:junit")
}

task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}

现在我运行> gradle build,我看到大量错误,提示“org.springframework.***不存在”

我想我需要以某种方式告诉 gradle 将 *.jar 文件包含在WebContent/WEB-INF/lib 目录,但不知道如何。

如果需要提供更多信息,请告诉我。

最佳答案

要添加来自 WebContent/WEB-INF/lib 和子文件夹的所有 jar 文件,您必须包含第一行:

 dependencies {
compile(fileTree(dir: "WebContent/WEB-INF/lib", include: "**/*.jar"))
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
testCompile("junit:junit")
}

关于java - 使用 gradle 而不是 eclipse 构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32442275/

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