标题:SpringJUnit4ClassRunner在juuit4中无法识别
只看楼主
飞逝的流年
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2020-8-27
结帖率:0
 问题点数:0 回复次数:0 
SpringJUnit4ClassRunner在juuit4中无法识别
大佬们,这个怎么,解决啊,求解

程序代码:
   <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.3.12</version>
        </dependency>


程序代码:
import cn.itcast.dao.CustomerDao;
import cn.itcast.domain.Customer;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.test.context.ContextConfiguration;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.Optional;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class SpecTest {
    @Autowired
    private CustomerDao customerDao;
    @Test
    public void testSpec(){
        Specification<Customer> spec = new Specification<Customer>() {
            @Override
            public Predicate toPredicate(Root<Customer> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
                criteriaBuilder.equal(custName,"张三");
                return null;
            }
        };
        Optional<Customer> customer = customerDao.findOne(spec);
        System.out.println(customer);
    }
}




[此贴子已经被作者于2021-11-15 08:51编辑过]

搜索更多相关主题的帖子: 识别 import version public test 
2021-11-13 21:03



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-507506-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.150845 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved