我正在尝试基于@JmsListener注释为发布 - 订阅创建示例:https://github.com/lkrnac/book-eiws-code-samples/tree/master/05-jms/0515-publish-subscribe
相关代码段:
@Slf4j
@SpringBootApplication
@EnableScheduling
public class JmsPublishSubscribeApplication {
public static void main(String[] args) throws InterruptedException {
SpringApplication.run(JmsPublishSubscribeApplication.class, args);
}
@Bean
public ActiveMQTopic simpleTopic() {
return new ActiveMQTopic("simpleTopic");
}
}
@Component
public class SimpleMessageListener1 {
@JmsListener(destination = "simpleTopic")
public void readMessage(String message) {
//....
}
}
@Component
public class SimpleMessageListener2 {
@JmsListener(destination = "simpleTopic")
public void readMessage(String message) {
//....
}
}
Run Code Online (Sandbox Code Playgroud)
问题是得到这种行为:
2015-05-17 20:07:04.985 INFO 22983 --- [pool-1-thread-1] n.l.b.e.chapter05.SimpleMessageSender : Sending message: simple message …Run Code Online (Sandbox Code Playgroud) 在我的控制器中,我有String参数,包含一些id,不应该是空字符串的null.我想知道,有没有办法检查它是不是@RequestMapping params中的空字符串?我试图在某些方面解决它
@RequestMapping(value = someURL, params = {"id"})
public SomeResponse doSomething(@RequestParam(required = true) String id)
@RequestMapping(value = someURL, params = {"!id="})
public SomeResponse doSomething(@RequestParam(required = true) String id)
@RequestMapping(value = someURL, params = {"!id=\"\""})
public SomeResponse doSomething(@RequestParam(required = true) String id)
Run Code Online (Sandbox Code Playgroud)
没有成功.据我了解,双方params = {"id"}并@RequestParam(required = true)只能检查参数id呈现在请求(!= NULL).
我很可能必须使用控制器boby中的代码检查它,例如
if (id == null || id.isEmpty()) {
return someErrorResponse;
}
Run Code Online (Sandbox Code Playgroud)
但如果我错了,请纠正我.提前致谢.
PS我的应用程序在Apache Tomcat 7.0.62容器中的Java 1.7 SE上运行
java spring spring-mvc hibernate-validator spring-annotations
我在执行gradle clean test命令时遇到问题.我的应用程序使用activiti进行工作流程.Git的网址:https://github.com/sanelib/eBOSS/tree/merge-before-dev 科:"合并前方的开发"是具有Activiti的worflow过程更多的测试.但是它只执行了来自"核心"模块的12个集成测试中的6个.如果我使用@Ignore进行任何随机的6次测试,那么它就会成功休息6.我已经调试了一些控制台,并发现它在启动activiti进程时挂起.
此源还在/ scripts文件夹中包含了数据库模式.如果您错过了在您的环境中进行测试所需的任何文件,请告诉我.
任何人都能看到这个并给我解决方案吗?
@ContextConfigurationlocation属性对Spring Boot集成测试没有意义.有没有其他方法可以在多个使用注释的测试类中重用应用程序上下文@SpringBootTest?
我在球衣测试框架上遇到了一些问题.如果我使用@Before和@After注释,则target方法抛出NullPointerException.我认为JerseyTest适用于JUnit?我的问题在哪里?
代码失败:
public class MyResourceTest extends JerseyTest {
@Before
public void setUp() { }
@After
public void tearDown() { }
@Override
protected Application configure() {
return new ResourceConfig(MyResource.class);
}
@Test
public void SHOULD_RETURN_BAD_REQUEST() throws IOException {
System.out.println(target("myPath"));
assertEquals(1, 1);
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
位于org.glassfish.jersey.test.JerseyTest.target(JerseyTest.java:566)的java.lang.NullPointerException,位于foo.bar.MyResourceTest的org.glassfish.jersey.test.JerseyTest.target(JerseyTest.java:580). SHOULD_RETURN_BAD_REQUEST(MyResourceTest.java:43)
有效的代码:
public class MyResourceTest extends JerseyTest {
@Override
protected Application configure() {
return new ResourceConfig(MyResource.class);
}
@Test
public void SHOULD_RETURN_BAD_REQUEST() throws IOException {
System.out.println(target("myPath"));
assertEquals(1, 1);
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
JerseyWebTarget { http://localhost:9998/myPath }
Run Code Online (Sandbox Code Playgroud) 我有一个以下的Spring Batch Job配置:
@Configuration
@EnableBatchProcessing
public class JobConfig {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Bean
public Job job() {
return jobBuilderFactory.get("job")
.flow(stepA()).on("FAILED").to(stepC())
.from(stepA()).on("*").to(stepB()).next(stepC())
.end().build();
}
@Bean
public Step stepA() {
return stepBuilderFactory.get("stepA").tasklet(new RandomFailTasket("stepA")).build();
}
@Bean
public Step stepB() {
return stepBuilderFactory.get("stepB").tasklet(new PrintTextTasklet("stepB")).build();
}
@Bean
public Step stepC() {
return stepBuilderFactory.get("stepC").tasklet(new PrintTextTasklet("stepC")).build();
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用以下代码开始工作:
try {
Map<String,JobParameter> parameters = new HashMap<>();
JobParameter ccReportIdParameter = new JobParameter("03061980");
parameters.put("ccReportId", ccReportIdParameter);
jobLauncher.run(job, new JobParameters(parameters));
} catch (JobExecutionAlreadyRunningException | JobRestartException | …Run Code Online (Sandbox Code Playgroud) 我有像这样的依赖字段
<List>
<select>
<option></option>
<option></option>
</select>
<select>
<option></option>
<option></option>
</select>
<input />
</List>
Run Code Online (Sandbox Code Playgroud)
如果我有5个<List/>组件.如何将Select2添加到每个组件.我在网上搜索.但找不到任何有效的解决方案.
react-select下面的代码.获取错误TypeError:event.target是未定义的.
var React = require('react');
var ReactDOM = require('react-dom');
var Select = require('react-select');
var Page = React.createClass({
getInitialState: function () {
return {
firstValue: ''
}
},
handleFirstLevelChange : function (event) {
this.setState({
firstValue: event.target.value
});
},
render : function(){
var options = [
{ value: '', label: 'Select an option' },
{ value: 'one', label: 'One' },
{ …Run Code Online (Sandbox Code Playgroud) 我从spring.io中读到了以下文档,By default Spring Boot will serve static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath但是当我将index.html文件放在/resources字符串下时,它就会index被渲染.目前index.html正在使用webapp,我正在使用AngularJS.
MvcConfiguration
@Configuration
public class MvcConfig {
@Bean
InternalResourceViewResolver viewResolver(){
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/webapp/");
resolver.setSuffix(".html");
return resolver;
}
}
Run Code Online (Sandbox Code Playgroud)
索引页面的Restful Service
@RestController
public class IndexController {
@RequestMapping("/")
public String index(){
System.out.println("Looking in the index controller.........");
return "index";
}
}
Run Code Online (Sandbox Code Playgroud)
在我的IDE控制台上,我确实看到Looking in the index controller......从IndexController和网络中打印出来的Chrome开发工具我只看到了localhost …
我正在尝试将Angular2与Springboot一起使用,但我无法将它们组合在一起.
我首先开始了一个springboot项目,然后尝试跟随johnpapa的Angular 2 Tour of Heroes并运行npm install.
结构如下所示:
我有/app文件夹,并.js编译为resources/static/app/js.
问题:
1)该文件夹resources/static/node_modules/有很多文件.因此,在运行时bootRun,它变得非常慢,有时甚至无法刷新文件.我相信我不应该把node_modules放在那里,但不确定..
2)npm install将文件放入./node_modules目前,我将它们复制到static文件夹中.我应该建立node_modules到static?
3)我的结构看起来很糟糕 ..最好的方法是什么?
如何设置这个结构?另外,如果我应该开始使用grunt/gulp或其他工具来让这更容易,请告诉我.
Ps.:如果有人对johnpapa的指南感兴趣:johnpapa的angular2指南
当请求映射中存在双星号时,这意味着什么?例如
@RequestMapping(value = { "/", "/welcome**" }, method =
RequestMethod.GET) public ModelAndView welcomePage() { ...
Run Code Online (Sandbox Code Playgroud) java ×8
spring ×7
spring-boot ×4
spring-mvc ×3
angularjs ×2
javascript ×2
activiti ×1
angular ×1
gradle ×1
jersey-2.0 ×1
junit ×1
junit4 ×1
overriding ×1
react-select ×1
reactjs ×1
select2 ×1
spring-batch ×1
spring-jms ×1
spring-test ×1