我正在尝试从 gradle 项目中调用 webAPI。
我的 build.gradle 如下。
plugins {
id 'org.springframework.boot' version '2.1.4.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile 'org.springframework.boot:spring-boot-starter-webflux'
compile 'org.projectreactor:reactor-spring:1.0.1.RELEASE'
}
如果我删除以下依赖项
compile 'org.springframework.boot:spring-boot-starter-webflux'
它有效,但如果我将其添加回来。它给出了错误
Web server failed to start. Port 8080 was already in use.
那么,我该如何解决这个问题,以便我可以使用 webclient?因为应用程序不是需要端口才能运行的 Web 应用程序。它是一种微服务。
我只想使用 Spring Boot 的 WebClient。如何在不将我的应用程序转换为 Web 应用程序的情况下使用它。
原文由 Anonymous Creator 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果您不想启动嵌入式服务器,只需在
application.properties
(或.yml
)中设置以下属性:来源: https ://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-web-servers.html
如果您的应用程序确实 是 Web 应用程序,那么您可以使用
server.port
属性轻松更改端口(在您的应用程序的.properties
/.yaml
文件中,as 命令启动时的行参数等)。