• Stars
    star
    267
  • Rank 153,621 (Top 4 %)
  • Language
    Java
  • Created over 8 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DDD START! μž¬μΆœκ°„νŒμΈ 도메인 주도 개발 μ‹œμž‘ν•˜κΈ° μ±…μ˜ μ†ŒμŠ€ μ½”λ“œλŠ” https://github.com/madvirus/ddd-start2 리포지토리에 확인 κ°€λŠ₯ν•©λ‹ˆλ‹€.

예제 μ•ˆλ‚΄

μ€€λΉ„

μ•„λž˜ ν”„λ‘œκ·Έλž¨μ„ μ€€λΉ„ν•œλ‹€.

  • JDK 1.8
  • 메이븐
  • MySQL

μ†ŒμŠ€ λ‹€μš΄λ‘œλ“œ

git을 μ•ˆλ‹€λ©΄ μ•„λž˜ λͺ…λ Ήμ–΄λ‘œ 리포지토리λ₯Ό ν΄λ‘ ν•œλ‹€.

git clone https://github.com/madvirus/ddd-start.git

git을 λͺ¨λ₯Έλ‹€λ©΄ 우츑 μƒλ‹¨μ˜ Download ZIP을 ν΄λ¦­ν•΄μ„œ μ½”λ“œλ₯Ό λ‹€μš΄λ‘œλ“œ λ°›κ³  압좕을 ν‘Όλ‹€.

MySQL DB 생성 및 데이터 μ΄ˆκΈ°ν™”

  • src/sql/ddl.sql νŒŒμΌμ„ μ΄μš©ν•΄μ„œ λ°μ΄ν„°λ² μ΄μŠ€μ™€ ν…Œμ΄λΈ” 생성
    • shop λ°μ΄ν„°λ² μ΄μŠ€ 생성
    • shopuser μ‚¬μš©μž 생성
    • κ΄€λ ¨ ν…Œμ΄λΈ” 생성
  • src/sql/init.sql 파일둜 예제 싀행에 ν•„μš”ν•œ 데이터 μ΄ˆκΈ°ν™”

docker-compose μ‚¬μš©μ‹œ

docker-compose up

JPA 메타λͺ¨λΈ 생성

OrderSummary_ 와 같이 이름에 '_'κ°€ ν¬ν•¨λœ JPA 메타 λͺ¨λΈ 클래슀λ₯Ό μƒμ„±ν•˜λ €λ©΄ λ‹€μŒ 쀑 ν•œ 방법을 μ‚¬μš©ν•œλ‹€.

  • mvn compile λͺ…λ Ήμ–΄λ‘œ 생성
  • mvn generate-sources λͺ…λ Ήμ–΄λ‘œ 생성

mvn compile λͺ…λ Ήμ–΄λ‘œ μƒμ„±ν•˜κΈ°

ν˜„μž¬ pom.xml νŒŒμΌμ€ mvn compile λͺ…λ Ήμ–΄λ₯Ό μ‹€ν–‰ν•˜λŠ” κ³Όμ •μ—μ„œ JPA λͺ¨λΈ 클래슀λ₯Ό μƒμ„±ν•œλ‹€. mvn compile λͺ…λ Ήμ–΄λ₯Ό μ‹€ν–‰ν•˜λ©΄ λ‹€μŒ 폴더에 메타λͺ¨λΈ ν΄λž˜μŠ€κ°€ μƒμ„±λœλ‹€.

  • target/generate-soruces/annotations

mvn generate-sources λͺ…λ Ήμ–΄λ‘œ μƒμ„±ν•˜κΈ°

generate-sources λͺ…λ Ήμ–΄λ‘œ μ‹€ν–‰ν•˜λ €λ©΄ pom.xml νŒŒμΌμ— λ‹€μŒκ³Ό 같이 maven-process-plugin 섀정을 μΆ”κ°€ν•œλ‹€.

            <!-- κΈ°μ‘΄ maven-compiler-plugin 주석 처리
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArguments>
                        <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                    </compilerArguments>
                </configuration>
            </plugin>
            -->

            <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <version>2.2.4</version>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <processors>
                                <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-jpamodelgen</artifactId>
                        <version>${hibernate.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

pom.xml 섀정을 λ³€κ²½ν–ˆμœΌλ©΄ λ‹€μŒ λͺ…λ Ήμ–΄λ₯Ό μ‹€ν–‰ν•œλ‹€.

$ mvn generate-sources

이 λͺ…λ Ήμ–΄λ₯Ό μ‹€ν–‰ν•˜λ©΄ target/generate-sources/apt 폴더에 메타λͺ¨λΈ ν΄λž˜μŠ€κ°€ μƒμ„±λœλ‹€.

예제 μ‹€ν–‰

ν”„λ‘œμ νŠΈ ν΄λ”μ—μ„œ λ‹€μŒ λͺ…λ Ήμ–΄λ‘œ 예제λ₯Ό μ‹€ν–‰ν•œλ‹€.

$ mvn spring-boot:run

http://localhost:8080에 μ ‘μ†ν•˜λ©΄ κ²°κ³Ό 화면을 λ³Ό 수 μžˆλ‹€.