问题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