Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
设置为7.0.1版的Gradle仍然不允许我安装java.servlet-api,因为它被贬低了_Java_Jsp_Gradle - Fatal编程技术网

设置为7.0.1版的Gradle仍然不允许我安装java.servlet-api,因为它被贬低了

设置为7.0.1版的Gradle仍然不允许我安装java.servlet-api,因为它被贬低了,java,jsp,gradle,Java,Jsp,Gradle,今天我开始学习Java servlet,但由于Gradle不允许我安装所需的依赖项,因此无法显示任何内容,出现以下错误: 我应该安装的东西还有 war,它似乎正在工作,但我无法安装java.servlet api C:\Users\Rayyan Khan\Desktop\projects\untitled>gradlew clean war > Configure project : Project : => no module-info.java found FAILUR

今天我开始学习Java servlet,但由于Gradle不允许我安装所需的依赖项,因此无法显示任何内容,出现以下错误:

我应该安装的东西还有 war,它似乎正在工作,但我无法安装
java.servlet api

C:\Users\Rayyan Khan\Desktop\projects\untitled>gradlew clean war

> Configure project :
Project : => no module-info.java found

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Rayyan Khan\Desktop\projects\untitled\build.gradle' line: 11

* What went wrong:
A problem occurred evaluating root project 'untitled'.
> Could not find method compileOnly() for arguments [{group=javax.servlet, name=javax.servlet-api, version=3.0.1}] on root project 'untitled' of type org.gradle.api.Project.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
我的build.gradle在这里:

plugins {
    id 'java'
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.9'
}

application {
    mainClassName = "Main"
}

compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'

apply plugin: 'war'
apply from: 'https://raw.github.com/gretty-gradle-plugin/gretty/master/pluginScripts/gretty.plugin'

group 'xenonmc.practice'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

javafx {
    version = "15.0.1"
    modules = ['javafx.controls']
}

dependencies {
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}

test {
    useJUnitPlatform()
}
和Gradle规格

C:\Users\Rayyan Khan\Desktop\projects\untitled>gradlew -version

------------------------------------------------------------
Gradle 7.0.1
------------------------------------------------------------

Build time:   2021-05-10 16:08:58 UTC
Revision:     67e618faef187783dadd03a34fdab9dc71b85b19

Kotlin:       1.4.31
Groovy:       3.0.7
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          15.0.2 (Oracle Corporation 15.0.2+7-27)
OS:           Windows 10 10.0 amd64

谢谢你的帮助

依赖项定义
compileOnly组:'javax.servlet',名称:'javax.servlet api',版本:'3.0.1'
(第11行)需要移动到构建脚本的
依赖项块中。查看和上的Gradle文档以了解更多信息。哦,好的,请稍候,谢谢!!成功了!!!!!!你愿意把它作为一个答案贴出来让我接受吗?因为你的问题是基于一个简单的错误,我决定直接在评论中解决它,并投票结束这个问题,因为它不太可能帮助未来的读者。请不要为此感到太难过。这是一个相当不错的第一个问题,包括了所有必要的信息。好的,谢谢D