There are many problems in spring boot unit test. When I use websocket, I will run the test class and report an error: error creating bean with name ‘serverendpoint exporter’ defined in class path resource [COM/Jacklin/config]/ WebSocketConfig.class ]Here I introduce the annotation @ serverendpoint:
There are two ways to solve this problem
Method 1: remove the @ runwith of the test class( SpringRunner.class ), but this method will have limitations. For example, when you want a @ authwired class below, you will report an error. I can’t do it here, according to your code situation.
The second way: add webenvironment after springboottest= SpringBootTest.WebEnvironment.RANDOM_ Port means to create a web application context (response based or servlet based). Reason: websocket depends on the startup of Tomcat and other containers. So in the process of testing, we need to really start a Tomcat as a container.
Run after adding, no more error!!
Read More:
- Error creating bean with name ‘datasource’ defined in class path resource
- Error creating bean with name ‘requestMappingHandlerAdapter‘ defined in class path resource
- Error creating bean with name ‘feignTargeter‘ defined in class path resource [org/springframework/cl
- Error creating bean with name ‘sqlsessionfactory’ defined in class path resource…..
- Error creating bean with name ‘lettuceClientResources‘ defined in class path resource
- Error creating bean with name ‘redisTemplate‘ defined in class path resource [xx/RedisConfig.class]
- Error creating bean with name ‘sqlsessionfactory’ defined in class path resource
- Error creating bean with name ‘configurationPropertiesBeans‘ defined in class path resource
- Error creating bean with name ‘entitymanagerfactory’ defined in class path resource
- Spring boot problem 1: error reporting life processing instructions for building a spring boot project
- Spring boot running appears java.lang.IllegalStateException : Failed to load ApplicationContext
- Spring AOP is an error creating bean with name
- Error creating bean with name ‘sqlsessionfactory’ defined in ServletContext resource)
- Spring boot project running error: Servlet.service () for servlet [dispatcherServlet] threw exception
- The springboot test class reported an error NullPointerException
- Spring boot problem solving record (1)
- The spring boot project was first created, pom.xml The error is Maven configuration problem. How to solve it?
- Error creating bean with name ‘application‘: Instantiation of bean failed;
- Record once the solution of gradle dependency problem: failed to determine a suitable driver class
- Spring configuration error: org.springframework.beans . factory.BeanCreationException : Error creating bean with name ‘m