Spring @Autowired在Kotlin
我在我的Kotlin代码中有一个@Autowire注释问题。 有一个代码完美的作品
@Controller open class PaymentController { @Autowired lateinit var autowiredBean: AutowiredBean @RequestMapping(value = "/SomePage", method = arrayOf(RequestMethod.GET)) fun somePage(@RequestParam("param") param: Int): ModelAndView { // some code } }
但添加一些安全检查后,@Autowire注释停止工作
@Controller open class PaymentController { @Autowired lateinit var autowiredBean: AutowiredBean @RequestMapping(value = "/SomePage", method = arrayOf(RequestMethod.GET)) @PreAuthorize("hasPermission('MODULE', 'FINANCE')") fun somePage(@RequestParam("param") param: Int): ModelAndView { // some code } }
这只是不初始化。 我试图通过我的控制器构造函数初始化它,但得到了相同的结果。 有任何想法吗?
- Kotlin无法在类中使用@Configuration @EnableWebMvc注释创建@Autowired字段
- 为springmvc使用kotlin无法实例化bean类的dataclass
- 来自YML的ConfigurationProperties加载列表
- Spring Web Flux(反应式)功能路由与Kotlin无法正常工作
- 使用Spring HATEOAS ControllerLinkBuilder和Kotlin抛出IllegalArgumentException
- 测试Spring的@Async void返回方法
- Kotlin NoClassDefFoundError和spring @RequestMapping方法
- 我可以写一个使用自动布线的Spring bean的Kotlin扩展函数吗?
- Spring Boot和Kotlin中的部分更新REST