https://stackoverflow.com/questions/35312677/how-to-use-month-using-aggregation-in-spring-data-mongo-dbAggregation 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();
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"
}
# 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
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
当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