springboot 使用druidDataSource,用配置文件自动配置,如果想把DataSource注入该怎么做 ?

工程中使用的式druidDataSource,没有写任何Java配置文件,直接使用properties文件创建的数据源。现在想使用shiro,jdbcreadlm使用时需要set数据源,我直接在配置文件上方使用autowired会报错。请问有什么解决方案么?。

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/random_recommend?characterEncoding=utf-8
spring.datasource.username=root
spring.datasource.password=root@password
#druid数据源需要的东西
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.druid.max-active=20
spring.datasource.druid.test-on-borrow=true
    @Autowired
    DruidDataSource druidDataSource;
    @ExceptionHandler(AuthorizationException.class)
    @ResponseStatus(HttpStatus.FORBIDDEN)
    public String handleException(AuthorizationException e, Model model) {

        // you could return a 404 here instead (this is how github handles 403, so the user does NOT know there is a
        // resource at that location)
        LogUtil.debug(this.getClass(),"AuthorizationException was thrown", e);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("status", HttpStatus.FORBIDDEN.value());
        map.put("message", "用户权限不足");
        model.addAttribute("errors", map);

        return "error403";
    }

    @Bean
    public Realm realm() {
        JdbcRealm jdbcRealm = new JdbcRealm();
        jdbcRealm.setDataSource(druidDataSource);
        jdbcRealm.setPermissionsLookupEnabled(true);
        String sqlQueryUserPassword = "select user_password from tb_sys_user where user_id = ?";
        jdbcRealm.setAuthenticationQuery(sqlQueryUserPassword);
        return jdbcRealm;
    }

报错信息贴出来啊,如果没有单独的配置类注入druid数据源名称为druidDataSource的话,注入的时候直接 @Autowired DataSource dataSource就好了;