Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java AOPINotificationException:在JUnit中的@Autowieired中_Java_Spring_Junit - Fatal编程技术网

Java AOPINotificationException:在JUnit中的@Autowieired中

Java AOPINotificationException:在JUnit中的@Autowieired中,java,spring,junit,Java,Spring,Junit,在我的java spring mvc应用程序中,我使用以下代码: 存储库: @Repository public interface TransactionRepository extends JpaRepository<Transactions ,Long >{ @Query(value = "SELECT sum( value) FROM Transactions inner join Customer on Transactions.customer_id=

在我的java spring mvc应用程序中,我使用以下代码:

存储库:

@Repository
public interface TransactionRepository  extends JpaRepository<Transactions ,Long >{

    @Query(value = "SELECT sum( value)  FROM Transactions  inner  join Customer on  Transactions.customer_id=Customer.id   where merchant_id= ?1 and age_class= ?2 ", nativeQuery=true)
    public double getOverAllValue(String merchantID,String ageGroup);


}
然后我尝试使用
junit
测试编写的服务:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = SEBApplication.class)
public class IncomeDataServiceTest {

    @Autowired 
    IncomeDataService incomeDataService;

    @Test
    public void testDataCollector() {
        System.out.println(incomeDataService.dataCollector(1));
    }

}
但是,当我运行测试时,它会抱怨:

org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract double ee.seb.domain.repository.TransactionRepository.getOverAllValue(java.lang.String,java.lang.String)

将查询的返回类型从原语数据类型
double
更新为
double
,因为您的查询可以返回
null
值,该值将由包装类而不是原语接受,因此您的最终查询如下:

@Query(value = "SELECT sum( value)  FROM Transactions  inner  join Customer on  Transactions.customer_id=Customer.id   where merchant_id= ?1 and age_class= ?2 ", nativeQuery=true)
    public Double getOverAllValue(String merchantID,String ageGroup);

将查询的返回类型从原语数据类型
double
更新为
double
,因为您的查询可以返回
null
值,该值将由包装类而不是原语接受,因此您的最终查询如下:

@Query(value = "SELECT sum( value)  FROM Transactions  inner  join Customer on  Transactions.customer_id=Customer.id   where merchant_id= ?1 and age_class= ?2 ", nativeQuery=true)
    public Double getOverAllValue(String merchantID,String ageGroup);

将查询的返回类型更改为包装类:Doubleoh man,thx。所以,
double
double
之间有什么区别呢?将查询的返回类型更改为包装类:Doubleoh-man,thx。那么
double
double
之间有什么区别呢?