spring - WAS 8.5.5.2:在类路径上未检测到 spring webapplicationinitializer 类型
问题描述
我有一个弹簧 mvc 项目。我正在尝试在 IBM Websphere 8.5.5.2 上部署这个项目
我为该项目构建了一场战争,并使用管理控制台将其部署在 Websphere 上
我正在使用基于 Java 的配置。我正在使用 AbstractAnnotationConfigDispatcherServletInitializer 和 WebMvcConfigurerAdapter 类进行配置。
但是当我部署应用程序时,我根据控制台得到以下信息: no spring Webapplicationinitializer types detected on classpath
并且没有触发spring初始化。
我的代码如下
@EnableWebMvc
@Configuration
@ComponentScan({ "com.demo" })
public class SpringWebConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
}
@Bean
public InternalResourceViewResolver viewResolver() {
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/jsp/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
}
public class MyWebInitializer extends
AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { SpringWebConfig.class };
}
}
@Controller
public class HelloController {
@RequestMapping(value = "/qwerty", method = RequestMethod.GET)
public String printWelcome() {
return "qwerty";
}
}
提前致谢 :)
解决方案
只是分享我的案例,可能对你有帮助。
我也部署了带有 JSP 的 springmvc servlet 作为 IBM WAS 8.5 的前端。我从服务器获得了相同的调试信息,但它不影响性能。
我在 servlet.xml 中的 internalViewResolver 和 resourceHandler 设置仍然有效。
[21/4/21 11:11:38:003 SGT] 000000a4 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [BP13BWDbPocWeb_war#BP13BWDbPocWeb.war]:.No Spring WebApplicationInitializer types detected on classpath
[21/4/21 11:11:38:015 SGT] 000000a4 webapp I com.ibm.ws.webcontainer.webapp.WebApp log SRVE0292I: Servlet Message - [BP13BWDbPocWeb_war#BP13BWDbPocWeb.war]:.Initializing Spring root WebApplicationContext
[21/4/21 11:11:38:016 SGT] 000000a4 ContextLoader I org.springframework.web.context.ContextLoader initWebApplicationContext Root WebApplicationContext: initialization started
推荐阅读
- c++ - 逆平方根内在函数
- javascript - 如何通过 jquery ajax 检查和接收 api 调用的结果
- node.js - 使用 RequireJs 时未从 Html 调用 Typescript 函数
- c++ - 使用宏计算源文件行数?
- javascript - 谷歌地图多个标记映射到一个没有坐标的区域
- django - 数据库重命名后django迁移不起作用
- html - 如何不只旋转图像周围的边框?
- python - 按列类型就地填充空值:TypeError:(“'NoneType'对象不可调用”,'发生在索引处
- r - 如何在 ShinyDashboard 中指定 menuItem?
- java - 支持 JavaFX + Spring Boot + Hibernate 应用程序中的多种环境