問題1: 項目啓動是時候異常 Error creating bean with name ‘requestMappingHandlerAdapter’ defined in class path resource
[20:38:58:137] [ERROR] – %1 – Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘requestMappingHandlerAdapter’ defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter]: Factory method ‘requestMappingHandlerAdapter’ threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘mvcConversionService’ defined in class path resource
解決:在Springboot主函數添加:
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class })
@EnableCaching
public class MallApplication {
public static void main(String[] args) {
System.setProperty("es.set.netty.runtime.available.processors","false");
SpringApplication.run(MallApplication.class, args);
}
}
問題2 :測試類啓動的時候遇到與上面相同問題
解決:在測試類添加:
public class ESTest {
static {
System.setProperty("es.set.netty.runtime.available.processors","false");
}
@Test
public void esTest() {
}
}
}
問題3:啓動後拋出異常
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{0rQzXgaYRXmWWEX6eH49VA}{127.0.0.1}{127.0.0.1:9300}]
]
注意這個大坑,
spring.data.elasticsearch.cluster-nodes=127.0.0.1:9300
spring.data.elasticsearch.cluster-name= my-application
cluster-name 不正確!!!!但是並不是這裏的問題!
需要打開ES目錄下config目錄下的的 elasticsearch.yml 文件
把 cluster-name = my-application 前面的註釋去掉!!!!太坑了wc