gpt4 book ai didi

java - Gradle 不编译 war 项目中的类

转载 作者:行者123 更新时间:2023-12-01 18:46:08 29 4
gpt4 key购买 nike

我使用 Eclipse 设置了以下项目:

project
build.gradle
libraries.gradle
settings.gradle
ear-project
build.gradle
ejb-project
build.gradle
war-project
build.gradle

这是根项目的 build.gradle:

apply from: "./libraries.gradle"

allprojects {
repositories {
mavenCentral()
}
}

buildscript {
repositories {
mavenCentral()
}
}

subprojects {
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "findbugs"

group = "foo.bar"
version = "1.0.0-SNAPSHOT"
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

configurations {
provided {
description = "Non-exported compile-time dependencies"
}
}

sourceSets.main {
compileClasspath += configurations.provided
}

eclipse {
classpath {
plusConfigurations += configurations.provided
}
}

dependencies {
provided(libraries.javaee)
provided(libraries.ejb)
provided(libraries.cdi)
provided(libraries.jpa)
}
}

ear-project build.gradle:

apply plugin: "ear"

dependencies {
deploy project(path: ":ejb")
deploy project(path: ":war", configuration: "archives")
}

ejb-项目 build.gradle

apply plugin: "java"

war 项目build.gradle

apply plugin: "war"

从命令行运行“gradle build”后,会生成 .ear 文件,但 .war 文件仅包含未编译的 .java 类。 ejb项目中的类被编译成.class。为什么war-project中的类没有被编译?

最佳答案

Java 文件必须位于 src/main/java 中。不是src/main/webappsrc/main/webapp是webapp静态资源所在目录:JSP文件、HTML文件、JS文件等

关于java - Gradle 不编译 war 项目中的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17763298/

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