0000-00-00 can not be represented as java.sql.Data 2018年3月12日 | Leave a comment 问题: 0000-00-00 can not be represented as java.sql.Data … Read More
Spring 事件驱动 @EventListener & ApplicationEventPublisher demo 2018年3月9日 | Leave a comment 解决: 不用 MQ 在 JVM spring 内进行event 发布订阅 App.java [crayon-6… Read More
Spring Boot + RabbitMQ demo 2018年3月9日 | Leave a comment 解决: Spring Boot + rabbitmq demo Java package demo.spmq1; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; import org.springframework.amqp.core.AmqpAdmin; import org.springframework.amqp.core.AmqpTemplate; import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.Binding.DestinationType; import org.springframework.amqp.core.Queue; import org.springframework.amqp.core.TopicExchange; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @SpringBootApplication @EnableScheduling public class App { private static final Logger LOG = Logger.getLogger(Sender.class.getName()); public static void main(String[] argv) { SpringApplication.run(App.class, argv); } @Component @Lazy(false) public static class Sender { final AmqpTemplate template; final AmqpAdmin admin; @Autowired public Sender(AmqpTemplate template, AmqpAdmin admin) { this.template = template; this.admin = admin; this.admin.declareExchange(new TopicExchange("ex1")); this.admin.declareQueue(new Queue("q2")); final Queue q1 = this.admin.declareQueue(); this.admin.declareBinding(new Binding("q2", DestinationType.QUEUE, "ex1", "", null)); this.admin.declareBinding(new Binding(q1.getName(), DestinationType.QUEUE, "ex1", "", null)); } @Scheduled(fixedRate = 1000) public void send() { LOG.info("send begin"); final Map<String, Object> map = new HashMap<>(); map.put("one", 1); map.put("t", new Date()); map.put("name", "你好"); template.convertAndSend("ex1", "", map); } } @Component @Lazy(false) public static class R2 { // @RabbitListener(bindings = { // @QueueBinding(exchange = @Exchange("ex1"), value = @Queue())}) @RabbitListener(queues = {"q2"}) public void onrecv(Map map) { System.out.println("R2 recv:" + map); } } } 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 package demo.spmq1; import java.util.Date;import java.util.HashMap;import java.util.Map;import java.util.logging.Logger;import org.springframework.amqp.core.AmqpAdmin;import org.springframework.amqp.core.AmqpTemplate;import org.springframework.amqp.core.Binding;import org.springframework.amqp.core.Binding.DestinationType;import org.springframework.amqp.core.Queue;import org.springframework.amqp.core.TopicExchange;import org.springframework.amqp.rabbit.annotation.RabbitListener;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.Lazy;import org.springframework.scheduling.annotation.EnableScheduling;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.stereotype.Component; @SpringBootApplication@EnableSchedulingpublic class App { private static final Logger LOG = Logger.getLogger(Sender.class.getName()); public static void main(String[] argv) { SpringApplication.run(App.class, argv); } @Component @Lazy(false) public static class Sender { final AmqpTemplate template; final AmqpAdmin admin; @Autowired public Sender(AmqpTemplate template, AmqpAdmin admin) { this.template = template; this.admin = admin; this.admin.declareExchange(new TopicExchange("ex1")); this.admin.declareQueue(new Queue("q2")); final Queue q1 = this.admin.declareQueue(); this.admin.declareBinding(new Binding("q2", DestinationType.QUEUE, "ex1", "", null)); this.admin.declareBinding(new Binding(q1.getName(), DestinationType.QUEUE, "ex1", "", null)); } @Scheduled(fixedRate = 1000) public void send() { LOG.info("send begin"); final Map<String, Object> map = new HashMap<>(); map.put("one", 1); map.put("t", new Date()); map.put("name", "你好"); template.convertAndSend("ex1", "", map); } } @Component @Lazy(false) public static class R2 {// @RabbitListener(bindings = {// @QueueBinding(exchange = @Exchange("ex1"), value = @Queue())}) @RabbitListener(queues = {"q2"}) public void onrecv(Map map) { System.out.println("R2 recv:" + map); } }} &nbs… Read More
Spring Boot + security + 定制 userDetailsService 2018年3月5日 | Leave a comment 问题: 解决: demo 定制 UserDetailsService [crayo… Read More
简单构建发布脚本 2018年3月2日 | Leave a comment 问题: 解决: #!/bin/bash # 构建打包上传 并重启 # /home/wms/start.sh begin ##!/bin/bash #cd `dirname $0` #nohup java -jar wms.war >> wms.log 2>&1 & # start.sh end # mvn clean -DskipTests=true install package scp -i ../docs/dev1 target/wms.war root@122.152.200.229:/root/ pid=`ssh -i ../docs/dev1 root@122.152.200.229 ps aux |grep java|grep -i wms|awk '{print $2}'` echo $pid ssh -i ../docs/dev1 root@122.152.200.229 kill $pid ssh -i ../docs/dev1 root@122.152.200.229 cp /root/wms.war /home/wms/ ssh -i ../docs/dev1 root@122.152.200.229 /home/wms/start.sh 1234567891011121314151617 #!/bin/bash# 构建打包上传 并重启 # /home/wms/start.sh begin##!/bin/bash#cd `dirname $0`#nohup java -jar wms.war >> wms.log 2>&1 &# start.sh end #mvn clean -DskipTests=true install packagescp -i ../docs/dev1 target/wms.war root@122.152.200.229:/root/pid=`ssh -i ../docs/dev1 root@122.152.200.229 ps aux |grep java|grep -i wms|awk '{print $2}'`echo $pidssh -i ../docs/dev1 root@122.152.200.229 kill $pidssh -i ../docs/dev1 root@122.152.200.229 cp /root/wms.war /home/wms/ssh -i ../docs/dev1 root@122.152.200.229 /home/wms/start.sh … Read More
spring boot 启用 cache 2018年2月24日 | Leave a comment 问题: spring boot 启用 cache 解决: 增加 @EnableCaching [… Read More
spring boot + security +mysql+ web demo 2018年2月24日 | Leave a comment 问题: 解决: 创建mysql表 [crayon-69350980432c5953… Read More
spring boot +mvc + security demo 2018年2月24日 | Leave a comment 问题: 解决: 运行后,访问 http://localhost:8080/user… Read More
retrofit demo 2018年2月14日 | Leave a comment 声明式 restful 接口 解决: App.java [crayon-6935098043c0… Read More