paulwong

#

spring data mongodb group by month

https://stackoverflow.com/questions/35312677/how-to-use-month-using-aggregation-in-spring-data-mongo-db
Aggregation agg = newAggregation(
    project("id")
        .andExpression("month(createdDate)").as("month_joined")
        .andExpression("year(createdDate)").as("year"),
    match(Criteria.where("year").is(2016)),
    group("month_joined").count().as("number"),
    project("number").and("month_joined").previousOperation(),
    sort(ASC, "number")
);

AggregationResults<JoinCount> results = mongoTemplate.aggregate(agg, 
                                                     "collectionName", JoinCount.class);
List<JoinCount> joinCount = results.getMappedResults();

posted @ 2020-12-11 16:53 paulwong 阅读(234) | 评论 (0)编辑 收藏

史上最通俗Netty入门长文:基本介绍、环境搭建、动手实战

http://www.blogjava.net/jb2011/archive/2020/11/18/435727.html

posted @ 2020-12-02 09:15 paulwong 阅读(304) | 评论 (0)编辑 收藏

Java的BIO和NIO很难懂?用代码实践给你看,再不懂我转行!

http://www.52im.net/thread-2846-1-1.html

posted @ 2020-12-02 08:52 paulwong 阅读(319) | 评论 (0)编辑 收藏

SPRING DATA MONGODB 教程


https://github.com/eugenp/tutorials/tree/master/persistence-modules/spring-data-mongodb

posted @ 2020-11-20 14:45 paulwong 阅读(275) | 评论 (0)编辑 收藏

LINUX SHELL之SCL

什么是SCL
https://blog.51cto.com/hashlinux/1772066

CentOS/RHEL 开发环境之 devtoolset
http://blog.fungo.me/2016/03/centos-development-env/

How can I make a Red Hat Software Collection persist after a reboot/logout?
https://access.redhat.com/solutions/527703

posted @ 2020-11-05 16:42 paulwong 阅读(744) | 评论 (0)编辑 收藏

Pretty print JSON using org.json library in Java

Syntax

public java.lang.String toString(int indentFactor) throws JSONException

Example

import org.json.*;
public class JSONPrettyPrintTest {
   
public static void main(String args[]) throws JSONException {
      String json 
= "{" +
                    
"Name : Jai," +
                    
"Age : 25, " +
                    
"Salary: 25000.00 " +
                    
"}";
      JSONObject jsonObj 
= new JSONObject(json);
      System.out.println(
"Pretty Print of JSON:");
      System.out.println(jsonObj.toString(
4)); // pretty print json
   }
}

Output

Pretty Print of JSON:
{
   "Salary": 25000,
   "Age": 25,
   "Name": "Jai"
}

posted @ 2020-10-28 17:17 paulwong 阅读(278) | 评论 (0)编辑 收藏

!!!服务器端各种安装

https://www.server-world.info/en/

posted @ 2020-10-24 23:46 paulwong 阅读(265) | 评论 (0)编辑 收藏

install redhat rh-mariadb103

# Install MariaDB 10.3
yum install rh-mariadb103-mariadb-server rh-mariadb103-mariadb-server-utils -y

# Add MariaDB 10.3 to $PATH
scl enable rh-mariadb103 bash
source /opt/rh/rh-mariadb103/enable

# start 10.3 server
chown -R mysql:mysql /var/opt/rh/rh-mariadb103/lib/mysql;
systemctl start rh-mariadb103-mariadb

# Upgrade tables
mysql_upgrade -p[PASSWORD]

# Set 10.3 to start on boot
systemctl enable rh-mariadb103-mariadb

# Add 10.3 to paths on reboot (and remove 10.2) 
rm /etc/profile.d/rh-mariadb102.sh
cp /opt/rh/rh-mariadb103/enable /etc/profile.d/rh-mariadb103.sh

# increase max connections number
systemctl edit rh-mariadb103-mariadb
[Service]
LimitNOFILE=65535
LimitNPROC=65535

vi /etc/opt/rh/rh-mariadb103/my.cnf
[mysqld]
max_connections=1000
open_files_limit=65535

# restart mariadb103
systemctl daemon-reload
systemctl restart rh-mariadb103-mariadb

# check result
mysql -e 'show variables like "max_connections"'

https://www.server-world.info/en/note?os=CentOS_7&p=mariadb103&f=4

posted @ 2020-10-24 18:02 paulwong 阅读(400) | 评论 (0)编辑 收藏

SPRING 中YAML文件密码不以明文保存

Update: for production environment, to avoid exposing the password in the command line, since you can query the processes with ps, previous commands with history, etc etc. You could:

  • Create a script like this: touch setEnv.sh
  • Edit setEnv.sh to export the JASYPT_ENCRYPTOR_PASSWORD variable

    #!/bin/bash

    export JASYPT_ENCRYPTOR_PASSWORD=supersecretz

  • Execute the file with . setEnv.sh
  • Run the app in background with mvn spring-boot:run &
  • Delete the file setEnv.sh
  • Unset the previous environment variable with: unset JASYPT_ENCRYPTOR_PASSWORD

https://stackoverflow.com/questions/37404703/spring-boot-how-to-hide-passwords-in-properties-file

posted @ 2020-10-20 14:59 paulwong 阅读(487) | 评论 (0)编辑 收藏

SPRING INTEGRATION HEADER问题

当SPRING INTEGRATION的流程中从HTTP outboundGateway转成JmsGateway时,会报header的错误,这时就要把相关多余的header移除。

.headerFilter("Api-Key", "Content-Type", "X-Powered-By", "Content-Language", "Transfer-Encoding", "Cache-Control", "Keep-Alive", "Set-Cookie")

https://stackoverflow.com/questions/50608415/cwsia0112e-the-property-name-keep-alive-is-not-a-valid-java-identifier

posted @ 2020-10-20 14:56 paulwong 阅读(353) | 评论 (0)编辑 收藏

仅列出标题
共119页: First 上一页 16 17 18 19 20 21 22 23 24 下一页 Last