【发布时间】:2018-09-24 07:08:12
【问题描述】:
我有一个非常简单的应用程序,我读到我可以使用 NettyServerCustomizer 来自定义 NettyServer。但它不起作用,没有调用 NettyServerCustomizer 接口的实现。 项目由 Spring Initializr 生成
申请代码:
@SpringBootApplication
@RestController
@RequestMapping("/test")
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@GetMapping
public Mono<String> test() {
return Mono.just("test");
}
@Bean
public NettyServerCustomizer nettyCustomizer() {
return builder -> builder.port(9909);
}
}
pom
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
【问题讨论】:
标签: spring-mvc spring-boot spring-webflux spring-web