- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 spring-boot
运行网络应用程序,并且必须使用使用 ContextLoader.getCurrentWebApplicationContext()
从中获取一些 bean 的外部工件。但它始终返回 null
。根据 spring-boot
文档,父应用程序上下文不是 WebApplicationContext
。有没有其他方法可以通过 ContextLoader.getCurrentWebApplicationContext()
访问 WebApplicationContext
?
提前致谢!
最佳答案
ContextLoader
并不真正适用于 Spring Boot 应用程序(或任何具有 Servlet 3.0 动态初始化的应用程序)。 Spring Boot 确实设置了 ServletContext
以便 WebApplicationContextUtils
可以找到 Web 上下文。您的外部工件确实不应该使用 ContextLoader
静态方法,因为它会假设应用程序的部署方式。你能改变它们吗?或者想出另一种方法来设置它们的状态?
关于spring - ContextLoader.getCurrentWebApplicationContext() 总是返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22167912/
我正在使用 spring-boot 运行网络应用程序,并且必须使用使用 ContextLoader.getCurrentWebApplicationContext() 从中获取一些 bean 的外部工
我正在尝试为我们的 spring mvc 应用程序中的 Controller 编写集成测试。 Controller 调用一个服务类,该服务类又调用一个 dao 从存储库中读取/写入数据。 DAO 需要
我是一名优秀的程序员,十分优秀!