[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</version>
 
    <dependencies>
        <!-- 필요한 의존성을 여기에 추가 -->
    </dependencies>
 
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <excludes>
                        <exclude>**/test/**</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
cs



2. mave.test.skip

1
mvn clean package -Dmaven.test.skip=true
cs

3. pom.xml (추가)

<properties> <maven.test.skip>true</maven.test.skip> </properties>


  • Gradle
1. groovy
jar {
    exclude '**/test/**'
}


2. build.gradle.kts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
plugins {
    kotlin("jvm") version "1.8.10"
}
 
repositories {
    mavenCentral()
}
 
dependencies {
    implementation(kotlin("stdlib"))
}
 
// 'test' 태스크를 실행하지 않도록 설정
tasks.withType<Test> {
    enabled = false
}
 
tasks.jar {
    // 'src/test' 폴더를 제외
    exclude("**/test/**")
}
 
cs

댓글

이 블로그의 인기 게시물

[Python] 리스트에서 특정 값 , 원소 위치, 원소 개수 찾기

[PHP] AWS S3 sdk 파일 업로드 하기