This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Resolves method arguments annotated with @{@link RequestParam}, arguments of | |
* type {@link MultipartFile} in conjunction with Spring's {@link MultipartResolver} | |
* abstraction, and arguments of type {@code javax.servlet.http.Part} in conjunction | |
* with Servlet 3.0 multipart requests. This resolver can also be created in default | |
* resolution mode in which simple types (int, long, etc.) not annotated with | |
* @{@link RequestParam} are also treated as request parameters with the | |
* parameter name derived from the argument name. | |
* <p>If the method parameter type is {@link Map}, the name specified in the | |
* annotation is used to resolve the request parameter String value. The value is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Inject Map using Value annotation and SpEL | |
values in application.properties: | |
value1=1000 | |
value2=2000 | |
code: | |
@Value("#{{KEY1: ${value1}, KEY2: ${value2}}}") | |
private Map<String, Integer> map = new HashMap<>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<configuration> | |
<!-- pass JVM args: -Dlog.file.location=custom.log -Dlog.level.root=TRACE --> | |
<!-- or defaults will be used : 'application.log' and 'DEBUG' --> | |
<!-- DEFAULT VALUE SEPARATOR IS ':-' NOT ':' AS SPRING USED --> | |
<property name="log.file.location" value="${log.file.location:-application.log}" /> | |
<property name="log.level.root" value="${log.level.root:-DEBUG}" /> | |
<appender name="file" class="ch.qos.logback.core.FileAppender"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Install rpm | |
sudo yum install name.rpm | |
2. Start stop service | |
sudo systemctl start service_name | |
sudo systemctl stop service_name | |
3.Install jdk | |
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-linux-x64.rpm" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**************************************************************** | |
//before | |
String dbName = "unknown"; | |
if (mongoOperations instanceof MongoTemplate) { | |
DB db = ((MongoTemplate) mongoOperations).getDb(); | |
if (db != null) { | |
dbName = db.getName() != null ? db.getName() : "unknown"; | |
} | |
} | |
//after |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. After running changeset changelog's file name is stored in table databasechangelog column filename. | |
During liquibase next run several filters check eligibilty for every changeset, one of them is ShouldRunChangeSetFilter | |
which checks: | |
idsAreEqual(changeSet, ranChangeSet) | |
&& authorsAreEqual(changeSet, ranChangeSet) | |
&& pathsAreEqual(changeSet, ranChangeSet) | |
so if path is different but content the same liquibase tries to run changeset anyway. | |
There is attribute to "hardcode" path and after that no matter what is the path to file. | |
Attribute is | |
logicalFilePath="upgrade/db-changelog.xml" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENTRY POINT TO GET ACTUAL VALUE FOR PLACEHOLDER!!! | |
org.springframework.core.env.PropertySourcesPropertyResolver#getPropertyAsRawString | |
order of property sources at context refresh: | |
adds new @PropertySource source | |
org.springframework.context.annotation.ConfigurationClassParser#addPropertySource | |
called from | |
org.springframework.context.annotation.ConfigurationClassParser#processPropertySource | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package company.artifact.persistence.liquibase.parser; | |
import liquibase.parser.LiquibaseParser; | |
import liquibase.parser.NamespaceDetails; | |
import liquibase.parser.core.xml.XMLChangeLogSAXParser; | |
import liquibase.serializer.LiquibaseSerializer; | |
import liquibase.serializer.core.xml.XMLChangeLogSerializer; | |
public class CustomNamespaceDetails implements NamespaceDetails { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
An index for a MySQL CLOB column cannot be created with Liquibase createIndex at the moment, | |
since MySQL requires a length limit for this index, see http://dev.mysql.com/doc/refman/5.5/en/create-index.html | |
As a workaround, you can use the modifySql to 'fix' the sql generated like so: | |
<createIndex tableName="foo" indexName="i_foo"> | |
<column name="myClobColumn"/> | |
</createIndex> | |
<modifySql dbms="mysql"> | |
<replace replace="myClobColumn" with="myClobColumn(80)"/> | |
</modifySql> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.github.tennaito.rsql.misc.ArgumentFormatException; | |
import com.github.tennaito.rsql.misc.DefaultArgumentParser; | |
import java.sql.Timestamp; | |
import java.time.ZonedDateTime; | |
import java.time.format.DateTimeFormatter; | |
// default DefaultArgumentParser can't parse Timestamps :( | |
public class CustomizedArgumentParser extends DefaultArgumentParser { |