기술나눔

pom.xml의 중요한 태그 소개

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Maven 프로젝트에서는pom.xml 파일은 프로젝트의 종속성, 플러그인, 빌드 구성 등을 정의하는 프로젝트 개체 모델(POM)의 구성 파일입니다.다음은pom.xml 파일의 몇 가지 중요한 태그와 해당 기능은 다음과 같습니다.

  1. <modelVersion>

    • POM 모델의 버전을 정의합니다.현재 일반적으로 사용되는 버전은4.0.0
    <modelVersion>4.0.0</modelVersion>
    
    • 1
  2. <groupId>

    • 일반적으로 조직이나 회사를 나타내는 프로젝트의 그룹 ID를 정의합니다.
    <groupId>com.example</groupId>
    
    • 1
  3. <artifactId>

    • 프로젝트의 이름인 프로젝트의 아티팩트 ID를 정의합니다.
    <artifactId>my-project</artifactId>
    
    • 1
  4. <version>

    • 프로젝트의 버전 번호를 정의합니다.
    <version>1.0.0</version>
    
    • 1
  5. <packaging>

    • 다음과 같이 프로젝트를 패키징하는 방법을 정의합니다. jarwarpom 기다리다.기본값은jar
    <packaging>jar</packaging>
    
    • 1
  6. <name>

    • 프로젝트의 이름입니다.
    <name>My Project</name>
    
    • 1
  7. <description>

    • 프로젝트에 대한 설명입니다.
    <description>This is a sample project</description>
    
    • 1
  8. <url>

    • 프로젝트의 홈페이지 URL입니다.
    <url>http://www.example.com</url>
    
    • 1
  9. <dependencies>

    • 프로젝트의 종속성을 정의합니다.각 종속성은 다음을 사용합니다.<dependency> 라벨 패키지.
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>5.3.8</version>
        </dependency>
    </dependencies>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
  10. <dependencyManagement>

    • 프로젝트 종속성을 중앙에서 관리하는 데 사용되는 버전입니다. 하위 모듈은 버전을 지정하지 않고도 이러한 종속성을 상속할 수 있습니다.
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-core</artifactId>
                <version>5.3.8</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
  11. <repositories>

    • 프로젝트가 의존하는 원격 저장소를 정의합니다.
    <repositories>
        <repository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2</url>
        </repository>
    </repositories>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  12. <build>

    • 플러그인 구성, 리소스 구성 등 빌드 관련 구성이 포함되어 있습니다.
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
  13. <properties>

    • Maven 빌드에서 변수를 정의합니다.
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    
    • 1
    • 2
    • 3
    • 4
  14. <profiles>

    • 다양한 환경에서 사용할 수 있는 다양한 빌드 구성을 정의합니다.
    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <env>development</env>
            </properties>
        </profile>
    </profiles>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

이 태그는 다음을 구성합니다. pom.xml Maven 프로젝트를 구성하고 관리하기 위한 기본 프레임워크입니다. 각 태그는 특정 목적을 수행하며 개발자가 프로젝트의 다양한 측면을 정의하는 데 도움이 됩니다.