title: How to implement Role Permission based system in Spring Boot
body: <p>I am trying to implement role permissions based system using spring boot and spring security. For this, I have taken an example from <a href="http://www.baeldung.com/role-and-privilege-for-spring-security-registration" rel="nofollow">http://www.baeldung.com/role-and-privilege-for-spring-security-registration</a>
  , but failed to do that.</p>
  
  <p><strong>Efforts</strong></p>
  
  <p><strong>SpringSecurity Configuration</strong></p>
  
  <pre><code>package com.insight;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.builders.WebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  import org.springframework.security.core.userdetails.UserDetailsService;
  import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  import org.springframework.security.crypto.password.PasswordEncoder;
  import org.springframework.security.web.authentication.AuthenticationFailureHandler;
  import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
  import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
  import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
  
  @Configuration
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
  
          @Autowired
          private UserDetailsService userDetailsService;
  
          @Autowired
          private AuthenticationSuccessHandler myAuthenticationSuccessHandler;
  
          @Autowired
          private LogoutSuccessHandler myLogoutSuccessHandler;
  
          @Autowired
          private AuthenticationFailureHandler authenticationFailureHandler;
  
          @Override
          protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
              auth.authenticationProvider(authProvider());
          }
  
          @Override
          public void configure(final WebSecurity web) throws Exception {
              web.ignoring().antMatchers("/resources/**");
          }
  
          @Override
          protected void configure(HttpSecurity httpSecurity) throws Exception {
              httpSecurity.authorizeRequests()
              .antMatchers("/js/**","/css/**","/images/**","/fonts/**").permitAll()
              .antMatchers("/user/signup/**","/about", "/","/user/login/").permitAll() // #4
              .anyRequest().authenticated() // 7
              .and()
              .formLogin().failureUrl("/user/login?error=true")
              .defaultSuccessUrl("/")
              .loginProcessingUrl("/user/validateLogin")
              .usernameParameter("email")
              .passwordParameter("password")
              .loginPage("/user/login")
              .permitAll()
              .and()
              .logout().logoutRequestMatcher(new AntPathRequestMatcher("/user/logout")).logoutSuccessUrl("/user/login")
              .permitAll();
          }
          @Bean
          public DaoAuthenticationProvider authProvider() {
              final DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
              authProvider.setUserDetailsService(userDetailsService);
              authProvider.setPasswordEncoder(encoder());
              return authProvider;
          }
  
          @Bean
          public PasswordEncoder encoder() {
              return new BCryptPasswordEncoder(11);
          }
      }
  </code></pre>
  
  <p><strong>User Model</strong></p>
  
  <pre><code>package com.insight.models;
  
  import java.util.Collection;
  import java.util.Date;
  import java.util.Set;
  
  import javax.persistence.CascadeType;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.JoinTable;
  import javax.persistence.OneToMany;
  import javax.persistence.OneToOne;
  import javax.persistence.PrePersist;
  import javax.persistence.PreUpdate;
  import javax.persistence.Table;
  import javax.validation.constraints.NotNull;
  import org.hibernate.validator.constraints.Email;
  
  @Entity
  @Table(name = "users")
  public class User {
  
  
       // An autogenerated id (unique for each user in the db)
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
  
        @OneToMany(mappedBy = "user", cascade = CascadeType.ALL)
        private Set&lt;Address&gt; addresses;
  
        @NotNull
        @OneToOne(cascade = CascadeType.ALL)
        @JoinColumn(name = "title")
        private Configuration title;
  
        @OneToOne(cascade=CascadeType.ALL)
          @JoinTable(name="user_roles",
              joinColumns = {@JoinColumn(name="user_id", referencedColumnName="id")},
              inverseJoinColumns = {@JoinColumn(name="role_id", referencedColumnName="id")}
          )
          private Collection&lt;Role&gt; roles;
  
        @NotNull
        private String firstName;
        @NotNull
        private String lastName;
  
        @NotNull
        @Column(unique = true)
        @Email
        private String email;
        @NotNull
        private String password;
  
        private String profileImage;
  
        @Column(name = "created_at")
        private Date createdAt;
        @Column(name = "created_by")
        private String createdBy;
  
        @Column(name = "updated_at")
        private Date updatedAt;
        @Column(name = "updated_by")
        private String updatedBy;
  
        private String status;
        private String deleteFlag;
        private String confirmationCode;
        private String lastLoginAt;
        private boolean enabled;
        private boolean tokenExpired;
  
        public User() {
              super();
              this.enabled = false;
          }
  
        @PrePersist
        void createdAt() {
          this.createdAt = this.updatedAt = new Date();
        }
  
        @PreUpdate
        void updatedAt() {
          this.updatedAt = new Date();
        }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public Set&lt;Address&gt; getAddresses() {
          return addresses;
      }
  
      public void setAddresses(Set&lt;Address&gt; addresses) {
          this.addresses = addresses;
      }
  
      public Configuration getTitle() {
          return title;
      }
  
      public void setTitle(Configuration title) {
          this.title = title;
      }
  
  
  
      public Collection&lt;Role&gt; getRoles() {
          return roles;
      }
  
      public void setRoles(Collection&lt;Role&gt; roles) {
          this.roles = roles;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getProfileImage() {
          return profileImage;
      }
  
      public void setProfileImage(String profileImage) {
          this.profileImage = profileImage;
      }
  
      public Date getCreatedAt() {
          return createdAt;
      }
  
      public void setCreatedAt(Date createdAt) {
          this.createdAt = createdAt;
      }
  
      public String getCreatedBy() {
          return createdBy;
      }
  
      public void setCreatedBy(String createdBy) {
          this.createdBy = createdBy;
      }
  
      public Date getUpdatedAt() {
          return updatedAt;
      }
  
      public void setUpdatedAt(Date updatedAt) {
          this.updatedAt = updatedAt;
      }
  
      public String getUpdatedBy() {
          return updatedBy;
      }
  
      public void setUpdatedBy(String updatedBy) {
          this.updatedBy = updatedBy;
      }
  
      public String getStatus() {
          return status;
      }
  
      public void setStatus(String status) {
          this.status = status;
      }
  
      public String getDeleteFlag() {
          return deleteFlag;
      }
  
      public void setDeleteFlag(String deleteFlag) {
          this.deleteFlag = deleteFlag;
      }
  
      public String getConfirmationCode() {
          return confirmationCode;
      }
  
      public void setConfirmationCode(String confirmationCode) {
          this.confirmationCode = confirmationCode;
      }
  
      public String getLastLoginAt() {
          return lastLoginAt;
      }
  
      public void setLastLoginAt(String lastLoginAt) {
          this.lastLoginAt = lastLoginAt;
      }
  
      public boolean isEnabled() {
          return enabled;
      }
  
      public void setEnabled(boolean enabled) {
          this.enabled = enabled;
      }
  
      public boolean isTokenExpired() {
          return tokenExpired;
      }
  
      public void setTokenExpired(boolean tokenExpired) {
          this.tokenExpired = tokenExpired;
      }
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = (prime * result) + ((email == null) ? 0 : email.hashCode());
          return result;
      }
  
      @Override
      public boolean equals(final Object obj) {
          if (this == obj) {
              return true;
          }
          if (obj == null) {
              return false;
          }
          if (getClass() != obj.getClass()) {
              return false;
          }
          final User user = (User) obj;
          if (!email.equals(user.email)) {
              return false;
          }
          return true;
      }
  
      @Override
      public String toString() {
          final StringBuilder builder = new StringBuilder();
          builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(email).append("]");
          return builder.toString();
      }
  
  }
  </code></pre>
  
  <p><strong>Role Model</strong></p>
  
  <pre><code>package com.insight.models;
  
  import java.util.Collection;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.JoinTable;
  import javax.persistence.ManyToMany;
  import javax.persistence.Table;
  
  @Entity
  @Table(name="roles")
  public class Role {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      private String name;
  
      @ManyToMany(mappedBy = "roles")
      private Collection&lt;User&gt; userRoles;
  
      @ManyToMany
      @JoinTable(
          name = "roles_privileges", 
          joinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"), 
          inverseJoinColumns = @JoinColumn(name = "permission_id", referencedColumnName = "id"))
      private Collection&lt;Permission&gt; permissions;
  
      public Role(String name) {
          this.name=name;
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Collection&lt;User&gt; getUserRoles() {
          return userRoles;
      }
  
      public void setUserRoles(Collection&lt;User&gt; userRoles) {
          this.userRoles = userRoles;
      }
  
      public Collection&lt;Permission&gt; getPermissions() {
          return permissions;
      }
  
      public void setPermissions(Collection&lt;Permission&gt; permissions) {
          this.permissions = permissions;
      }
  
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result + ((name == null) ? 0 : name.hashCode());
          return result;
      }
  
      @Override
      public boolean equals(final Object obj) {
          if (this == obj) {
              return true;
          }
          if (obj == null) {
              return false;
          }
          if (getClass() != obj.getClass()) {
              return false;
          }
          final Role role = (Role) obj;
          if (!role.equals(role.name)) {
              return false;
          }
          return true;
      }
  
      @Override
      public String toString() {
          final StringBuilder builder = new StringBuilder();
          builder.append("Role [name=").append(name).append("]").append("[id=").append(id).append("]");
          return builder.toString();
      }
  }
  </code></pre>
  
  <p><strong>Permission Model</strong></p>
  
  <pre><code>package com.insight.models;
  
  import java.util.Collection;
  
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.ManyToMany;
  
  public class Permission {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      private String name;
  
      @ManyToMany(mappedBy = "permissions")
      private Collection&lt;Role&gt; roles;
  
      public Permission(String name2) {
          name = name;
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Collection&lt;Role&gt; getRoles() {
          return roles;
      }
  
      public void setRoles(Collection&lt;Role&gt; roles) {
          this.roles = roles;
      }
  
      @Override
      public int hashCode() {
          final int prime = 31;
          int result = 1;
          result = prime * result + ((name == null) ? 0 : name.hashCode());
          return result;
      }
  
      @Override
      public boolean equals(Object obj) {
          if (this == obj)
              return true;
          if (obj == null)
              return false;
          if (getClass() != obj.getClass())
              return false;
          Permission other = (Permission) obj;
          if (name == null) {
              if (other.name != null)
                  return false;
          } else if (!name.equals(other.name))
              return false;
          return true;
      }
  
      @Override
      public String toString() {
          final StringBuilder builder = new StringBuilder();
          builder.append("Permission [name=").append(name).append("]").append("[id=").append(id).append("]");
          return builder.toString();
      }
  }
  </code></pre>
  
  <p><strong>pom.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.insight&lt;/groupId&gt;
      &lt;artifactId&gt;insight&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &lt;name&gt;insight&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;1.3.5.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-thymeleaf&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.thymeleaf.extras&lt;/groupId&gt;
              &lt;artifactId&gt;thymeleaf-extras-springsecurity4&lt;/artifactId&gt;
          &lt;/dependency&gt;
           &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
           &lt;/dependency&gt;
           &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-mail&lt;/artifactId&gt;
              &lt;version&gt;1.3.6.RELEASE&lt;/version&gt;&lt;!--$NO-MVN-MAN-VER$--&gt;
           &lt;/dependency&gt;
           &lt;dependency&gt;
              &lt;groupId&gt;org.passay&lt;/groupId&gt;
              &lt;artifactId&gt;passay&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
           &lt;/dependency&gt;
           &lt;dependency&gt;
              &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
              &lt;artifactId&gt;guava&lt;/artifactId&gt;
              &lt;version&gt;19.0&lt;/version&gt;
           &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;    
  &lt;/project&gt;
  </code></pre>
  
  <p><strong>CustomUserDetailsService</strong></p>
  
  <pre><code>package com.insight.services;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collection;
  import java.util.List;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.context.MessageSource;
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.authority.SimpleGrantedAuthority;
  import org.springframework.security.core.userdetails.UserDetails;
  import org.springframework.security.core.userdetails.UserDetailsService;
  import org.springframework.security.core.userdetails.UsernameNotFoundException;
  import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  
  import com.insight.models.Permission;
  import com.insight.models.Role;
  import com.insight.models.User;
  import com.insight.repositories.RoleRepository;
  import com.insight.repositories.UserRepository;
  
  
  
  @Service("userDetailsService")
  @Transactional
  public class CustomUserDetailsService implements UserDetailsService {
  
      @Autowired
      private UserRepository userRepository;
      @Autowired
      private IUserService service;
      @Autowired
      private MessageSource messages;
      @Autowired
      private RoleRepository roleRepository;
  
      @Override
      public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
          User user = userRepository.findByEmail(email);
          if (user == null) {
              return new org.springframework.security.core.userdetails.User(
                " ", " ", true, true, true, true, 
                getAuthorities(Arrays.asList(roleRepository.findByName("ROLE_USER"))));
          }
  
          return new org.springframework.security.core.userdetails.User(
            user.getEmail(), user.getPassword(), user.isEnabled(), true, true, 
            true, getAuthorities(user.getRoles()));
      }
  
      private Collection&lt;? extends GrantedAuthority&gt; getAuthorities(Collection&lt;Role&gt; roles) {
          return getGrantedAuthorities(getPrivileges(roles));
      }
  
      private List&lt;String&gt; getPrivileges(Collection&lt;Role&gt; roles) {
          List&lt;String&gt; privileges = new ArrayList&lt;String&gt;();
          List&lt;Permission&gt; collection = new ArrayList&lt;Permission&gt;();
          for (Role role : roles) {
              collection.addAll(role.getPermissions());
          }
          for (Permission item : collection) {
              privileges.add(item.getName());
          }
          return privileges;
      }
  
      private List&lt;GrantedAuthority&gt; getGrantedAuthorities(List&lt;String&gt; privileges) {
          List&lt;GrantedAuthority&gt; authorities = new ArrayList&lt;GrantedAuthority&gt;();
          for (String privilege : privileges) {
              authorities.add(new SimpleGrantedAuthority(privilege));
          }
          return authorities;
      }
  }
  </code></pre>
  
  <p>There some etc. classes also there, but I am not posting due to large segment, if anyone requires specifics, I will post.</p>
  
  <p>When I tried to run, I am getting following error on console:</p>
  
  <blockquote>
    <p>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.core.userdetails.UserDetailsService com.insight.SecurityConfiguration.userDetailsService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.insight.repositories.UserRepository com.insight.services.CustomUserDetailsService.userRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#778bd3a2' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#778bd3a2': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
            at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) ~[spring-beans-4.2.6.RELEASE.jar:4.2.6.RELEASE]
            at </p>
  </blockquote>
  
  <p>Please friends help me.</p>