I am trying to perform Spring Security Authentication using MyBatis.

My spring-security file looks as follows

```
        <global-method-security pre-post-annotations="enabled" />

       <beans:bean id="myUserService"                    
                 class="com.service.CustomService" />

            <authentication-manager>
                <authentication-provider user-service-ref="myUserService" />
            </authentication-manager>

```

My CustomService class `implements UserDetailsService` and in the `loadUserByUsername` method , I am using my MyBatis Dao to load the Users from the DB.

```
@Autowired
private MyBatisDao dao;

```

In my Controller class I am using the same annotation , and in that case it returns the proper object.

But when I use the same in the CustomService class it returns `null`. 

I am unable to understand the reason for it. Am i missing something. Please help

Any example of Spring Authentication using MyBatis would help, I can understand it and then maybe figure out the issue