jagadeesh-Gs-MacBook:Contact jagadeeshgundlapalle$ gradle
:help
Welcome to Gradle 2.2.1.
To run a build, run gradle <task> ...
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle --help
BUILD SUCCESSFUL
Total time: 16.4 secs
jagadeesh-Gs-MacBook:Contact jagadeeshgundlapalle$ gradle jar
:compileJava
/Users/jagadeeshgundlapalle/Documents/workspace3/Contact/src/main/java/gurukul/ContactListController.java:4: package org.springframework.web.bind.annotation does not exist
import org.springframework.web.bind.annotation.RequestMapping;
^
/Users/jagadeeshgundlapalle/Documents/workspace3/Contact/src/main/java/gurukul/ContactListController.java:5: package org.springframework.web.bind.annotation does not exist
import org.springframework.web.bind.annotation.RequestParam;
^
/Users/jagadeeshgundlapalle/Documents/workspace3/Contact/src/main/java/gurukul/ContactListController.java:6: package org.springframework.web.bind.annotation does not exist
import org.springframework.web.bind.annotation.RestController;
^
/Users/jagadeeshgundlapalle/Documents/workspace3/Contact/src/main/java/gurukul/ContactListController.java:9: cannot find symbol
symbol: class RestController
@RestController
^
/Users/jagadeeshgundlapalle/Documents/workspace3/Contact/src/main/java/gurukul/ContactListController.java:14: cannot find symbol
symbol : class RequestMapping
location: class gurukul.ContactListController
@RequestMapping("/getList")
^
5 errors
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 11.53 secs
将spring-web.jar添加到你的依赖项中:
org.springframework:spring-web:<your spring version>.RELEASE
当我尝试使用 gradle 使用 spring boot 构建一个项目时,我遇到了类似的问题。默认情况下,Springboot 项目是在 build.gradle 文件中使用此引用创建的:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}}
更改了此引用:
org.springframework.boot:spring-boot-starter
为此:
org.springframework.boot:spring-boot-starter-web
它对我有用。
更改了此引用:
implementation 'org.springframework.boot:spring-boot-starter
对此:
implementation 'org.springframework.boot:spring-boot-starter-web
它对我有用。