title: Spring boot - Not a managed type
body: <p>I use Spring boot+JPA and having a problem while starting the service.</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.nervytech.dialer.domain.PhoneSettings
      at org.hibernate.jpa.internal.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:219)
      at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.&lt;init&gt;(JpaMetamodelEntityInformation.java:68)
      at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:65)
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:145)
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:89)
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:69)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:177)
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239)
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225)
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
  </code></pre>
  
  <p>Here is the Application.java file,</p>
  
  <pre><code>@Configuration
  @ComponentScan
  @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })
  @SpringBootApplication
  public class DialerApplication {
  
      public static void main(String[] args) {
          SpringApplication.run(DialerApplication.class, args);
      }
  }
  </code></pre>
  
  <p>I use UCp for connection pooling and the DataSource configuration is below,</p>
  
  <pre><code>@Configuration
  @ComponentScan
  @EnableTransactionManagement
  @EnableAutoConfiguration
  @EnableJpaRepositories(entityManagerFactoryRef = "dialerEntityManagerFactory", transactionManagerRef = "dialerTransactionManager", basePackages = { "com.nervy.dialer.spring.jpa.repository" })
  public class ApplicationDataSource {
  
      /** The Constant LOGGER. */
      private static final Logger LOGGER = LoggerFactory
              .getLogger(ApplicationDataSource.class);
  
      /** The Constant TEST_SQL. */
      private static final String TEST_SQL = "select 1 from dual";
  
      /** The pooled data source. */
      private PoolDataSource pooledDataSource;
  </code></pre>
  
  <p>UserDetailsService Implementation,</p>
  
  <pre><code>@Service("userDetailsService")
  @SessionAttributes("user")
  public class UserDetailsServiceImpl implements UserDetailsService {
  
      @Autowired
      private UserService userService;
  </code></pre>
  
  <p>Service layer implementation,</p>
  
  <pre><code>@Service
  public class PhoneSettingsServiceImpl implements PhoneSettingsService {
  
  }
  </code></pre>
  
  <p>The repository class,</p>
  
  <pre><code>@Repository
  public interface PhoneSettingsRepository extends JpaRepository&lt;PhoneSettings, Long&gt; {
  
  }
  </code></pre>
  
  <p>Entity class,</p>
  
  <pre><code>@Entity
  @Table(name = "phone_settings", catalog = "dialer")
  public class PhoneSettings implements java.io.Serializable {
  </code></pre>
  
  <p>WebSecurityConfig class,</p>
  
  <pre><code>@Configuration
  @EnableWebMvcSecurity
  @ComponentScan
  public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      private UserDetailsServiceImpl userDetailsService;
  
      /**
       * Instantiates a new web security config.
       */
      public WebSecurityConfig() {
  
          super();
      }
  
      /**
       * {@inheritDoc}
       * @see org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter#configure(org.springframework.security.config.annotation.web.builders.HttpSecurity)
       */
      @Override
      protected void configure(HttpSecurity http) throws Exception {
  
          http.authorizeRequests()
              .antMatchers("/login", "/logoffUser", "/sessionExpired", "/error", "/unauth", "/redirect", "*support*").permitAll()
              .anyRequest().authenticated().and().rememberMe().and().httpBasic()
              .and()
              .csrf()
              .disable().logout().deleteCookies("JSESSIONID").logoutSuccessUrl("/logoff").invalidateHttpSession(true);
      }
  
  
      @Autowired
      public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
  
        auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder());
      }
  
  }
  </code></pre>
  
  <p>The packages are as follows,</p>
  
  <ol>
  <li><code>Application</code> class is in - <code>com.nervy.dialer</code></li>
  <li><code>Datasource</code> class is in - <code>com.nervy.dialer.common</code></li>
  <li>Entity classes are in - <code>com.nervy.dialer.domain</code></li>
  <li>Service classes are in - <code>com.nervy.dialer.domain.service.impl</code></li>
  <li>Controllers are in - <code>com.nervy.dialer.spring.controller</code></li>
  <li>Repository classes are in - <code>com.nervy.dialer.spring.jpa.repository</code></li>
  <li><code>WebSecurityConfig</code> is in - <code>com.nervy.dialer.spring.security</code></li>
  </ol>
  
  <p>Thanks</p>