我有一个非常基本的Spring Boot应用程序,它期望来自命令行的参数,并且没有它不起作用.这是代码.
@SpringBootApplication
public class Application implements CommandLineRunner {
    private static final Logger log = LoggerFactory.getLogger(Application.class);
    @Autowired
    private Reader reader;
    @Autowired
    private Writer writer;
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
    @Override
    public void run(String... args) throws Exception {
        Assert.notEmpty(args);
        List<> cities = reader.get("Berlin");
         writer.write(cities);
    }
}
Run Code Online (Sandbox Code Playgroud)
这是我的JUnit测试类.
@RunWith(SpringRunner.class)
@SpringBootTest
public class CityApplicationTests {
    @Test
    public void contextLoads() {
    }
}
Run Code Online (Sandbox Code Playgroud)
现在,Assert.notEmpty()要求传递一个论点.但是,现在,我正在编写JUnit测试.但是,我得到了以下异常加注Assert.
2016-08-25 16:59:38.714 ERROR 9734 --- [           main] o.s.boot.SpringApplication               : Application startup failed …Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个应该使用单页React前端的网页.对于后端,我正在使用spring boot框架.
所有api调用都应使用前缀为url的URL,/api并应由REST控制器处理.
所有其他网址应该只是提供index.html文件.如何用弹簧实现这一目标?
我正在为实体列表实现搜索/过滤服务,使用具有规范和分页功能的 Spring Data JPA 存储库。我正在尝试减少查询次数(n+1 问题)并使用标准获取机制获取嵌套数据。
我有两个实体类:
@Entity
@Table(name = "delegations")
public class Delegation {
    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;
    @ManyToOne
    private Customer customer;
    // more fields, getters, setters, business logic...
}
Run Code Online (Sandbox Code Playgroud)
和
@Entity
@Table(name = "customers")
public class Customer {
    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;
    // more fields, getters, setters, business logic...
}
Run Code Online (Sandbox Code Playgroud)
DTO过滤器类:
public class DelegationFilter {
    private String customerName;
    // more filters, getters, setters...
}
Run Code Online (Sandbox Code Playgroud)
和搜索/过滤服务:
public class DelegationService {
    public Page<Delegation> findAll(DelegationFilter …Run Code Online (Sandbox Code Playgroud) spring ×3
java ×2
spring-boot ×2
hibernate ×1
junit ×1
spring-data ×1
spring-mvc ×1
unit-testing ×1