在网上找了半天都没解决,最后才发现是springMvc配置类
@EnableWebMvc这个注解被我注释掉了
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.EnableWebMvc; @Configuration @ComponentScan({"com.hncj.controller", "com.hncj.config"}) @EnableWebMvc public class SpringMvcConfig { }
这玩意是真坑,Junit测试的时候要注释掉才能测试service,在Tomcat上部署时得打开才行