본문 바로가기
Spring

maven 정리 (2)

by dharana7723 2023. 2. 5.

maven 기본 디렉토리 구조
maven 기본 설정 파일인 pom.xml 파일이 프로젝트 root에 위치
- 기본 소스 코드 디렉토리
- src/main/언어명
- java: src/main/java
- groovy: src/main/groovy
- 테스트 코드 디렉토리
- src/test/java
- compile 결과 디렉토리
- target


pom.xml 기본 구조
- 프로젝트 정보
- modelVersion
- groupId
- artifactId
- version
- packagin

<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blidkaga.group</groupId>
<artifactId>group-test</artifactId>
<name>test</name>
<packagin>war</packagin>
<version>1.0.0-SNAPSHOT</version>
</project>


- properties
- maven 내부에서 반복적으로 사용될 상수 값을 정의 할때 사용
- <properties>
<java-version>1.6</java-version>
<org.springframework-version>3.1.1RELEASE</org.springframework-version>
<org.ascpetj-version>1.6.10</org.aspectj-version>
<org.sl4j-version>1.6.6</org.slf4j-version>
</properties>
<dependencies>
 <dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>${org.springframework-version}</version>
  <exclusions>
  <exclusion>
  <groupId>commons-logging</groupId>
  <artifactId>commons-loggin</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${org.springframework-version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

- dependencies (의존성 라이브러리 정보)
- project 태그 바로 하위
- 의존성 라이브러리 정보를 포함함
- 최소 groupId, artifactId, version 정보가 필요함
- dependencies 섹션 아래 세부 'dependency'가 기술됨

....생략
<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
        <exclusions>
       <exclusion>
           <groupId>commons-loggin</groupId>
           <artifactId>commons-logging<artifactId>
        </exclusion>
    </exclusions>
<scope>provided</scope>
</dependency>


-빌드 정보
    - project 태그 바로 하위
    - plugins: 빌드에서 사용할 플러그인
    - 디렉토리 구조
<build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <outputDirectory>${project.basedir}/target/classes/</outputDirectory>
    <resources>
       <resource>
           <directory>src/main/resources/</directory>
           <filtering>true/</filtering>
      </resource>
      <resource>
         <directory>resources-${deploy.phase}/</directory>
         <filtering>true</filtering>
     </resource>
     <plugins>
        <plugin>
           <groupId>org.apache.maven.plugins</gropuId>
           <artifactId>maven-compiler-plugin</artifactId>
           <version>2.5.1</version>
           <configuration>
               <soure>1.6</source>
               <target>1.6</target>
               <compilerArgument>-Xlint:all</compilerArguemnt>
               <showWarnings>true</showWarnings>
               <showDeprecation>true</showDeprecation>
        </configuration>
    </plugin>
    </plugin>
    </plugins>
</build>

- repository
-  의존성을 다운로드 받을 위치의 repository
- 기술되지 않을 시 기본적인 위치
http://repo.maven.apache.org/maven2
- 다수의 <repository> 기술 가능
- 회사 내부의 repository를 기술하기도 한다.
- nexus, artifactory를 이용


- plugin repostiory
- maven plugin을 다운로드 받을 수 있는 저장소 위치를 기술

- 배포
- deploy goal을 실행했을 시 배포되는 위치를 기술함
- ulr 항목에는 일반적으로 회사 내부에 설치한 repository url이 기술된다 (nexus, artifactory 등등으로 설치된)

<distributionManagement> 
   <repository> 
       <id>releases-repo</id> 
       <name>Releases Repository</name> 
       <url>일반적인 회사 내부 repository url</url     
  </repository> 
  <snapshotRepository>
       <id>snapshots-repo</id> 
       <name>Snapshots Repository</name>
        <url>일반적인 회사 내부 repository url</url> </snapshotRepository>
</distributionManagement>

'Spring' 카테고리의 다른 글

대규모 트래픽 -캐시 영상 정리  (2) 2024.01.09
maven 정리 (3)  (0) 2023.02.05
maven 정리  (0) 2023.02.04
의존성 주입과 초기화  (0) 2022.07.26
스프링 : AOP  (0) 2022.07.22