我试图在Spring Batch中配置几个数据源.在启动时,Spring Batch抛出以下异常:
To use the default BatchConfigurer the context must contain no more thanone DataSource, found 2
批量配置的代码段
@Configuration
@EnableBatchProcessing
public class BatchJobConfiguration {
@Primary
@Bean(name = "baseDatasource")
public DataSource dataSource() {
// first datasource definition here
}
@Bean(name = "secondaryDataSource")
public DataSource dataSource2() {
// second datasource definition here
}
...
}
Run Code Online (Sandbox Code Playgroud)
不知道为什么我看到这个异常,因为我已经看到一些基于xml的Spring批处理配置声明了多个数据源.我使用Spring Batch核心版本3.0.1.RELEASE与Spring Boot版本1.1.5.RELEASE.任何帮助将不胜感激.
我有一个使用 Spring 云配置 (--spring.profiles.active=native) 的应用程序,并在同一应用程序中提供一些 html 页面。一切都很好,直到我引入静态资源(src/main/resources/css/bootstrap-switch.css)。对http://localhost:8080/css/bootstrap-switch.css的 URL 调用失败并出现此异常:
{"timestamp":1438114326940,"status":406,"error":"Not Acceptable","exception":"org.springframework.web.HttpMediaTypeNotAcceptableException","message":"Could not find acceptable representation","path":"/css/bootstrap-switch.css"}
Run Code Online (Sandbox Code Playgroud)
当我禁用@EnableConfigServer 时,URL 返回 CSS 内容。我使用的是 Spring Cloud Config 版本 1.0.2。
这是我可以重现此问题的极简代码:
@SpringBootApplication
@EnableConfigServer
public class Application {
public static void main(String args[]) {
SpringApplication.run(ApplicationConfiguration.class, args);
}
}
@Configuration
@SpringBootApplication
class ApplicationConfiguration {
@Bean
public TestController testController() {
return new TestController();
}
@Bean
public MvcController mvcController() {
return new MvcController();
}
}
@RestController
class TestController {
@RequestMapping("/test")
@ResponseBody
public String test() {
return "hello …
Run Code Online (Sandbox Code Playgroud)