小编Tia*_*nça的帖子

不适合所有BeanPostProcessors处理的类

我在Maven中设置Spring + Spring Data JPA + QueryDSL + JPA 2.0 + Hibernate时遇到了很多麻烦.我已经解决了很多问题,但是这个问题让我很头疼= /.

我收到以下异常:

Bean 'dataSource' of type [class org.springframework.jdbc.datasource.DriverManagerDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
Run Code Online (Sandbox Code Playgroud)

我在谷歌看了一下,大多数时候这个问题是由缺少注释"@Transactional"引起的.我试图注释我的方法,但它没有解决任何问题.我绝对不知道它来自哪里=(.

这是我测试的代码:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/applicationContext.xml")
public class BaseTest {

    public BaseTest() {
    }

    @Before
    public void setUp() throws IOException {
        Dataset.loadDatabase();
    }

    @Test
    public void load(){}
}
Run Code Online (Sandbox Code Playgroud)

DataSet类只是在db中做一些保存,看看它是否正常工作.

我的ApplicationContext.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context-3.1.xsd
       http://www.springframework.org/schema/data/jpa
       http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">

        <context:annotation-config/>
        <jpa:repositories base-package="com.ae.repository" …
Run Code Online (Sandbox Code Playgroud)

spring unit-testing hibernate jpa-2.0

27
推荐指数
1
解决办法
5万
查看次数

标签 统计

hibernate ×1

jpa-2.0 ×1

spring ×1

unit-testing ×1