7월, 2024의 게시물 표시

[Querydsl] 멀티 DB (Multi DB) 연결, 설정하기

1. application.yml에 데이터소스 추가하기 Spring Boot 프로젝트에서 두 개의 데이터베이스를 사용하기 위해 application.yml 파일에 각각의 데이터소스를 정의해줍니다. spring: datasource: driverClassName: org.mariadb.jdbc.Driver url: jdbc:mariadb://localhost:3306/{DB명} username: {DB user} password: {DB password} second-datasource: driverClassName: org.mariadb.jdbc.Driver url: jdbc:mariadb://localhost:3306/{DB명} username: {DB user} password: {DB password} 2. 데이터소스 설정 1) 첫 번째 데이터베이스 설정 기본 데이터베이스 설정을 위해 @Primary 어노테이션을 사용해야 하며, 관련된 설정을 아래와 같이 구성합니다. @Configuration @EnableTransactionManagement @EnableJpaRepositories( basePackages = ["패키지1", "패기지2"], entityManagerFactoryRef = "entityManagerFactory", transactionManagerRef = "transactionManager" ) class DatasourceConfig { @Bean @Primary @ConfigurationProperties("spring.datasource") fun datasourceProperties(): DataSourceProperties { return DataSourceProperties() ...

jar 파일 빌드 시 테스트 파일 제외

jar 파일로 빌드 시에 test 파일에서 에러 나거나 용량을 줄이고 싶다면 test 파일을 제외한 후 빌드할 수 있다  Maven 사용 1. pom.xml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 < project xmlns = "http://maven.apache.org/POM/4.0.0"            xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"            xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0                               http://maven.apache.org/xsd/maven-4.0.0.xsd" >      < modelVersion > 4. 0. 0 < / modelVersion >      < groupId > com.example < / groupId >      < artifactId > your - artifact - id < / artifactId >      < version > 1. 0 - SNAPSHOT ...