Tag: autowired

Spring注入util:在Kotlin中映射types安全

我在XML中有几个bean定义来存储我的SQL外部。 我想把它们作为Map注入到Kotlin中Map但是到目前为止,我只能将它注入到Map 。 有没有一种方法来确保types安全。 将它注入为Map会感觉到贫民窟。 当我尝试Map甚至Map我得到不符合条件豆find… XML示例 注入服务 @Service open class JdbcBrandService @Autowired constructor( private val namedJdbcTemplate: NamedParameterJdbcTemplate ): BrandService { companion object { val logger = LoggerFactory.getLogger(JdbcBrandService::class.java) } @Autowired @Qualifier(value = “brandSql”) private lateinit var queries: Map /// methods and what not go here } 在Java中,我可以用类似下面这样的方式逃脱,但Kotlin的types系统更严格似乎阻止了这一点。 @RestController public class JavaBrandController { private final Map […]

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 { // […]