Skip to content

Instantly share code, notes, and snippets.

View yusufcakal's full-sized avatar
:octocat:
Leave your code better than you found it

Yusuf Çakal yusufcakal

:octocat:
Leave your code better than you found it
View GitHub Profile
@yusufcakal
yusufcakal / BaseService.java
Last active January 22, 2020 12:05
Application Decorator Pattern in Java
public interface BaseService<T extends BaseRequest, R extends BaseResponse> {
R execute(T request);
}
docker build -f Dockerfile -t config-server:latest .
docker run -e ACTIVE_PROFILE=default -e CONFIG_GIT_REPO_NAME=xxx-configs -e CONFIG_GIT_USERNAME=username -e CONFIG_GIT_PASSWORD=password -p 8089:8089 -it config-server:latest
docker build -f Dockerfile -t config-server:latest .
FROM adoptopenjdk:11-jre-hotspot
ADD target/*.jar ./srv
WORKDIR /srv
EXPOSE 8089
ENV ACTIVE_PROFILE ${ACTIVE_PROFILE}
ENV CONFIG_GIT_REPO_NAME ${CONFIG_GIT_REPO_NAME}
ENV CONFIG_GIT_USERNAME ${CONFIG_GIT_USERNAME}
ENV CONFIG_GIT_PASSWORD ${CONFIG_GIT_PASSWORD}
CMD java -Dspring.profiles.active=$ACTIVE_PROFILE -jar /srv/*.jar
@yusufcakal
yusufcakal / application.yml
Created November 27, 2019 20:38
config server application.yml file example
spring:
profiles: default
cloud:
config:
server:
git:
uri: http://{baseUrl}/config-server/${CONFIG_GIT_REPO_NAME}.git
clone-on-start: true
username: ${CONFIG_GIT_USERNAME}
password: ${CONFIG_GIT_PASSWORD}
@yusufcakal
yusufcakal / ConfigServerApplication.java
Created November 20, 2019 05:58
Config Server Main Class
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
@yusufcakal
yusufcakal / LogExecutionTime.java
Last active July 7, 2019 19:36
This custom annotation shows execution time that used method via aspect oriented programming in spring.
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface LogExecutionTime {
}
@yusufcakal
yusufcakal / gist:73bba046739551dfe31dd5134b9e375c
Created June 11, 2019 16:39
SpringOne19' Istanbul Useful Links
https://www.callicoder.com/hibernate-spring-boot-jpa-embeddable-demo/
https://www.baeldung.com/java-optional-or-else-vs-or-else-get
https://refactoring.guru/smells/feature-envy
https://www.mkyong.com/unittest/junit-4-tutorial-2-expected-exception-test/
https://www.javacodegeeks.com/2013/02/testing-expected-exceptions-with-junit-rules.html
https://www.geeksforgeeks.org/luhn-algorithm/
http://baddotrobot.com/blog/2012/03/27/expecting-exception-with-junit-rule/
https://github.com/r2dbc
https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html
https://github.com/snicoll-demos/spring-boot-migration/tree/master/src/main/java/com/example/speakerservice
@yusufcakal
yusufcakal / BaseControllerIntegrationTest.java
Created June 6, 2019 18:23
Util class for controller integration test in spring boot
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles("test")
public abstract class BaseControllerIntegrationTest {
@PersistenceContext
protected EntityManager entityManager;
@Autowired
@yusufcakal
yusufcakal / LiquibaseConfig.java
Created May 25, 2019 16:03
Config class for liquibase
import liquibase.integration.spring.SpringLiquibase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.Assert;
import javax.sql.DataSource;