hql组合条件查sum的方法

@Query("select sum(r.amount) from RechargeOrder r where 1=1  " +
            "AND (case when (:status is null) then true when(:status=r.status) then true else false end)=true " +
            "AND (case when (:walletType is null) then true when(:walletType=r.walletType) then true else false end)=true " +
            "AND (case when (:payType is null) then true when(:payType=r.payType) then true else false end)=true " +
            "AND (case when (:userId is null) then true when(:payType=r.userId) then true else false end)=true " +
            "AND (case when (:rechargeType is null) then true when(:rechargeType=r.rechargeType) then true else false end)=true " +
            "AND (case when (:successTimeBegin is null) then true when(:successTimeBegin<=r.successTime) then true else false end)=true " + "AND (case when (:successTimeEnd is null) then true when(:successTimeEnd>=r.successTime) then true else false end)=true " +

            "")
    Integer sumAmount(
            @Param("status")  Integer status
            ,@Param("walletType")  Integer walletType
            ,@Param("payType")  Integer payType
            ,@Param("userId")  Integer userId
            ,@Param("rechargeType")  Integer rechargeType
            ,@Param("successTimeBegin")  Date successTimeBegin
            ,@Param("successTimeEnd")  Date successTimeEnd
    );

swagger-ui在spring-cloud里无法设置basepath的坑

在springcloud里网关做的路由,隐藏了微服务的名称。
单发现无论怎么设置host和basepath都没效果,结果发现是版本的坑
用2.6.1是可以的2.7设置无效。

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>


	

hadoop windows中 at java.lang.ProcessBuilder.start(ProcessBuilder.java:1010)

at java.lang.ProcessBuilder.start(ProcessBuilder.java:1010)

windows出现的话需要额外的设置

下载

http://dlwt.csdn.net/fd.php?i=960183934596561&s=567f6d47ccc446b43fc82d38bbdba0cc

hadoop util 放 HADOOP/bin, 增加环境变量

吧hadoop.dll 复制到system32

hadoop2.6 配置注意点

终于能用了,都快崩溃了
ERROR org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: Exception in doCheckpoint
和之前种种异常,
列下需要注意的地方:

1:9000和9001, 这俩设置成统一的
2:虚拟机iptables 要关掉,有可能把端口封掉
3:hostname 跟hosts里设置成一样的会比较方便,生成id_rsa.pub的时候里面的路径就自动跟计算机名一致了
4: 我是用虚拟机的,1个master 1个slave 在slaves里把 master,slave1都加上了。

额外的诡异问题,配置好后运行无异常。但用测试demo,wordcount无法生成输出内容。
什么都没动,没关机器,第二天又自己好了。。

Entity Bean 需要实现 Serializable 否则 。。

服务端异常
23:53:29,131 ERROR [org.jboss.as.ejb3] (Remoting “wslhkpc” task-7) JBAS014248: 消息 Channel ID 3367520a (inbound) of Remoting connection 34916e44 to /127.0.0.1:62015 里的频道 org.jboss.remoting3.remote.InboundMessage$3@345c347c 上的异常: java.io.IOException: Stream is closed
at org.xnio.streams.BufferPipeOutputStream.closed(BufferPipeOutputStream.java:62) [xnio-api-3.0.10.GA-redhat-1.jar:3.0.10.GA-redhat-1]
at org.xnio.streams.BufferPipeOutputStream.checkClosed(BufferPipeOutputStream.java:68) [xnio-api-3.0.10.GA-redhat-1.jar:3.0.10.GA-redhat-1]
at org.xnio.streams.BufferPipeOutputStream.write(BufferPipeOutputStream.java:94) [xnio-api-3.0.10.GA-redhat-1.jar:3.0.10.GA-redhat-1]
at org.jboss.remoting3.remote.OutboundMessage.write(OutboundMessage.java:270) [jboss-remoting-3.3.1.Final-redhat-1.jar:3.3.1.Final-redhat-1]
at java.io.DataOutputStream.write(DataOutputStream.java:107) [rt.jar:1.8.0_11]
at org.jboss.as.ejb3.remote.protocol.AbstractMessageHandler$1.write(AbstractMessageHandler.java:217)
at org.jboss.marshalling.OutputStreamByteOutput.write(OutputStreamByteOutput.java:52) [jboss-marshalling-1.4.6.Final-redhat-1.jar:1.4.6.Final-redhat-1]
at org.jboss.marshalling.SimpleDataOutput.shallowFlush(SimpleDataOutput.java:353) [jboss-marshalling-1.4.6.Final-redhat-1.jar:1.4.6.Final-redhat-1]
at org.jboss.marshalling.river.RiverMarshaller.writeString(RiverMarshaller.java:1509)
at org.jboss.marshalling.river.RiverMarshaller.writeNewSerializableClass(RiverMarshaller.java:1415)
at org.jboss.marshalling.river.RiverMarshaller.writeNewClass(RiverMarshaller.java:1345)
at org.jboss.marshalling.river.RiverMarshaller.writeClass(RiverMarshaller.java:1199)
at org.jboss.marshalling.river.RiverMarshaller.writeNewSerializableClass(RiverMarshaller.java:1438)
at org.jboss.marshalling.river.RiverMarshaller.writeSerializableClass(RiverMarshaller.java:1398)
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:884)
at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58) [jboss-marshalling-1.4.6.Final-redhat-1.jar:1.4.6.Final-redhat-1]
at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111) [jboss-marshalling-1.4.6.Final-redhat-1.jar:1.4.6.Final-redhat-1]
at org.jboss.as.ejb3.remote.protocol.AbstractMessageHandler.writeException(AbstractMessageHandler.java:112)
at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.processMessage(MethodInvocationMessageHandler.java:166)
at org.jboss.as.ejb3.remote.protocol.versionone.VersionOneProtocolChannelReceiver.handleMessage(VersionOneProtocolChannelReceiver.java:160)
at org.jboss.remoting3.remote.RemoteConnectionChannel$5.run(RemoteConnectionChannel.java:452) [jboss-remoting-3.3.1.Final-redhat-1.jar:3.3.1.Final-redhat-1]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_11]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_11]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_11]
Caused by: an exception which occurred:
in object java.io.EOFException@5a234c92

客户端异常
Exception in thread “main” java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:, moduleName:TestEJB, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext@69a3d1d
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:735)
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:116)
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183)
at org.jboss.ejb.client.EJBClientInvocationContext.retryRequest(EJBClientInvocationContext.java:208)
at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:256)
at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:265)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)
at com.sun.proxy.$Proxy3.createCabin(Unknown Source)
at client.ClientTest.date(ClientTest.java:155)
at client.ClientTest.main(ClientTest.java:28)

————-
出现原因:Entity Bean 必须实现 Serializable

jboss eap 6.3 mysql数据源错误提示 JBAS010441

配置mysql数据源出现错误提示:
failure description: “JBAS010441: Failed to load module for driver
中文日志是无法加载模块

环境是jboss eap 6.3

网上找了n种答案,虽然不是我的问题,还是列举一下
答案1,说是版本问题,要mysql-5.1.30一下的
答案2,配置问题 eap的配置跟老版本的不太一样,得用modules
反正大家配置都差不多怎么都出不来,

我这里最后是因为这个:

看jboss自带的module.xml木有这行,去掉就好使了!!

ejb3 javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter,

ejb里面报异常 javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter,

其实就是个很简单的错误,需要引用jboss-client.jar 重点是合适的版本!
网上随便下了个jboss-client4.jar的包,一直报这个异常,其实就是缺少类

从jboss里复制一个新版本出来就好用了

jvm优化

可能出现的异常:
OutOfMemoryError:java heap size
OutOfMemoryError: PermGen space”

两种都是内存溢出,
heap size是说申请不到新的内存了,这个很常见,检查应用或调整堆内存大小。
“PermGen space”是因为永久存储区满了,这个也很常见,一般在热发布的环境中出现,是因为每次发布应用系统都不重启,久而久之永久存储区中的死对象太多导致新对象无法申请内存,一般重新启动一下即可。

tomcat设置自动加载的时候可能会出现

在声明的时候注意点,别在循环里声明新对象,不用了给设null,如果还不够就得考虑增加jvm最大内存数了。。

为什么会产生StackOverflowError?
答:因为一个线程把Stack内存全部耗尽了,一般是递归函数造成的。

参考:
http://blog.csdn.net/chinajane163/article/details/7784521

ActiveMQ helloworld

apache官网下载了5.9.1很扯淡的,3次无法解压成功,换了4次镜像,算是解压好了。。。
activemq.bat运行显示:

WARN | Store limit is 102400 mb (current store usage is 0 mb). The data directo
ry: E:\workspace\apache-activemq-5.9.1\bin\..\data\kahadb only has 35873 mb of u
sable space – resetting to maximum available disk space: 35873 mb
ERROR | Temporary Store limit is 51200 mb, whilst the temporary data directory:
E:\workspace\apache-activemq-5.9.1\bin\..\data\localhost\tmp_storage only has 35
873 mb of usable space – resetting to maximum available 35873 mb.

出了个错误,不过能正常使用,
目前还不知道有什么影响。

后台地址
http://localhost:8161/admin
admin/admin
可以正常打开

运行webappdemo
提示
missing brokerURL (specified via org.apache.activemq.brokerURL init-Param) or embedded broker

呃呃,又找了个简单例子:
代码来源:http://blog.csdn.net/jason5186/article/details/9196041
发送:
public class JmsSender {
public static void main(String[] args) throws JMSException{
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(“tcp://127.0.0.1:61616”);

Connection connection = connectionFactory.createConnection();
connection.start();
;// connection.

Session session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(“Test.foo”);

MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
for(int i=0; i<100; i++) { int id = i+1; ObjectMessage message = session.createObjectMessage(); message.setObject(new User(id, "张三"+id, "123456")); producer.send(message); } session.commit(); session.close(); connection.close(); } } 之后能在后台看见队列中的内容 接收 public class JmsReceiver { public static void main(String[] args) throws JMSException, InterruptedException{ ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://127.0.0.1:61616"); Connection connection = connectionFactory.createConnection(); connection.start(); final Session session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue("Test.foo"); MessageConsumer consumer = session.createConsumer(destination); //listener 方式 consumer.setMessageListener(new MessageListener() { public void onMessage(Message msg) { ObjectMessage message = (ObjectMessage) msg; //TODO something.... try { User user = (User) message.getObject(); System.out.println("收到消息:"+user); } catch (JMSException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { session.commit(); } catch (JMSException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); TimeUnit.MINUTES.sleep(1); session.close(); connection.close(); } }