springboot配置接口文档报错
时间: 2023-10-15 21:22:58 浏览: 93
根据提供的引用内容,springboot配置接口文档报错的问题可以通过以下两种方式解决。
首先,在es的配置类中使用@PostConstruct注解进行初始化设置。具体代码如下:
```
@Configuration
public class ElasticSearchConfig {
@PostConstruct
void init() {
System.setProperty("es.set.netty.runtime.available.processors", "false");
}
@Bean
public TransportClient esClient() throws UnknownHostException {
Settings settings = Settings.builder()
.put("cluster.name", "xunwu")
.put("client.transport.sniff", true)
.build();
@SuppressWarnings("resource")
TransportClient client = new PreBuiltTransportClient(settings)
.addTransportAddress(new TransportAddress(InetAddress.getByName("192.168.111.132"), 9300));
return client;
}
}
```
其次,如果第一种方式还是不行,可以在启动main函数中设置系统属性。具体代码如下:
```
@SpringBootApplication
public class App {
public static void main(String[] args) {
System.setProperty("es.set.netty.runtime.available.processors", "false");
SpringApplication.run(App.class, args);
}
}
```
以上两种方法都可以解决springboot配置接口文档报错的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [springboot整合es启动报错的问题](https://blog.csdn.net/zhangcongyi420/article/details/88617660)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [springBoot集成Swagger报错处理](https://blog.csdn.net/King_3123/article/details/125651813)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文