日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

jpa 托管_Spring Boot-不是托管类型

發(fā)布時間:2023/12/2 javascript 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 jpa 托管_Spring Boot-不是托管类型 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我使用Spring boot + JPA,啟動服務(wù)時遇到問題。

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.(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)

這是Application.java文件,

@Configuration

@ComponentScan

@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class })

@SpringBootApplication

public class DialerApplication {

public static void main(String[] args) {

SpringApplication.run(DialerApplication.class, args);

}

}

我使用UCp進(jìn)行連接池,下面是DataSource配置,

@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;

UserDetailsService Implementation,

@Service("userDetailsService")

@SessionAttributes("user")

public class UserDetailsServiceImpl implements UserDetailsService {

@Autowired

private UserService userService;

Service layer implementation,

@Service

public class PhoneSettingsServiceImpl implements PhoneSettingsService {

}

The repository class,

@Repository

@Repository

public interface PhoneSettingsRepository extends JpaRepository {

}

Entity class,

@Entity

@Table(name = "phone_settings", catalog = "dialer")

public class PhoneSettings implements java.io.Serializable {

WebSecurityConfig class,

@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());

}

}

軟件包如下,

Application class is in - com.nervy.dialer

Datasource class is in - com.nervy.dialer.common

Entity classes are in - com.nervy.dialer.domain

Service classes are in - com.nervy.dialer.domain.service.impl

Controllers are in - com.nervy.dialer.spring.controller

Repository classes are in -com.nervy.dialer.spring.jpa.repository

WebSecurityConfig is in - com.nervy.dialer.spring.security

謝謝

總結(jié)

以上是生活随笔為你收集整理的jpa 托管_Spring Boot-不是托管类型的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。