CodeGym /Java Course /๋ชจ๋“ˆ 3 /๋ฉ”์ด๋ธ ์†์„ฑ

๋ฉ”์ด๋ธ ์†์„ฑ

๋ชจ๋“ˆ 3
๋ ˆ๋ฒจ 1 , ๋ ˆ์Šจ 6
์‚ฌ์šฉ ๊ฐ€๋Šฅ

7.1 Maven์˜ ๋ณ€์ˆ˜ - ์†์„ฑ

์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜ Maven์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ณ€์ˆ˜์— ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” pom ํŒŒ์ผ์˜ ๋‹ค๋ฅธ ๋ถ€๋ถ„์— ์žˆ๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ผ์น˜์‹œ์ผœ์•ผ ํ•  ๋•Œ ๋งค์šฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด Java ๋ฒ„์ „, ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฒ„์ „, ํŠน์ • ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ๊ฒฝ๋กœ๋ฅผ ๋ณ€์ˆ˜์— ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

pom.xml โ€“ <properties>์ด๋ฅผ ์œ„ํ•ด ์—๋Š” ๋ณ€์ˆ˜๊ฐ€ ์„ ์–ธ๋˜๋Š” ํŠน์ˆ˜ ์„น์…˜์ด ์žˆ์Šต๋‹ˆ๋‹ค . ๋ณ€์ˆ˜์˜ ์ผ๋ฐ˜์ ์ธ ํ˜•์‹์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

<variable-name> _ _ _ _meaning< / variable name > _

์˜ˆ:

<properties>
    <junit.version>5.2</junit.version>
    <project.artifactId>new-app</project.artifactId>
    <maven.compiler.source>1.13</maven.compiler.source>
    <maven.compiler.target>1.15</maven.compiler.target>
</properties>

๋ณ€์ˆ˜๋Š” ๋‹ค๋ฅธ ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ์•ก์„ธ์Šค๋ฉ๋‹ˆ๋‹ค.

$ { variable -name } _

๊ทธ๋Ÿฌํ•œ ์ฝ”๋“œ๊ฐ€ ์ž‘์„ฑ๋œ ๊ณณ์—์„œ Maven์€ ๋ณ€์ˆ˜์˜ ๊ฐ’์„ ๋Œ€์ฒดํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ:

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
 
<build>
    <finalName>${project.artifactId}</finalName>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
            <source>${maven.compiler.source}</source>
            <target>${maven.compiler.target}</target>
        </configuration>
    </plugin>
</build>

7.2 Maven์˜ ๋ฏธ๋ฆฌ ์ •์˜๋œ ๋ณ€์ˆ˜

pom ํŒŒ์ผ์—์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ์„ค๋ช…ํ•  ๋•Œ ๋ฏธ๋ฆฌ ์ •์˜๋œ ๋ณ€์ˆ˜๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์กฐ๊ฑด๋ถ€๋กœ ์—ฌ๋Ÿฌ ๊ทธ๋ฃน์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  • ๋‚ด์žฅ ํ”„๋กœ์ ํŠธ ์†์„ฑ
  • ํ”„๋กœ์ ํŠธ ์†์„ฑ;
  • ์„ค์ •.

๊ธฐ๋ณธ ์ œ๊ณต ํ”„๋กœ์ ํŠธ ์†์„ฑ์€ ๋‘ ๊ฐ€์ง€๋ฟ์ž…๋‹ˆ๋‹ค.

์žฌ์‚ฐ ์„ค๋ช…
${basedir} ํ”„๋กœ์ ํŠธ ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌpom.xml
${๋ฒ„์ „} ์•„ํ‹ฐํŒฉํŠธ ๋ฒ„์ „; ์‚ฌ์šฉํ•  ์ˆ˜ ${project.version}์žˆ๊ฑฐ๋‚˜${pom.version}

ยซprojectยปํ”„๋กœ์ ํŠธ ์†์„ฑ์€ ๋˜๋Š” ์ ‘๋‘์‚ฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ฐธ์กฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค ยซpomยป. ๋„ค ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

์žฌ์‚ฐ ์„ค๋ช…
${ํ”„๋กœ์ ํŠธ.๋นŒ๋“œ.๋””๋ ‰ํ† ๋ฆฌ} ยซtargetยปํ”„๋กœ์ ํŠธ ๋””๋ ‰ํ† ๋ฆฌ
${project.build.outputDirectory} ยซtargetยป์ปดํŒŒ์ผ๋Ÿฌ ๋””๋ ‰ํ† ๋ฆฌ. ๊ธฐ๋ณธยซtarget/classesยป
${ํ”„๋กœ์ ํŠธ ์ด๋ฆ„} ํ”„๋กœ์ ํŠธ์˜ ์ด๋ฆ„
${ํ”„๋กœ์ ํŠธ.๋ฒ„์ „} ํ”„๋กœ์ ํŠธ ๋ฒ„์ „

์†์„ฑ์€ settings.xml์ ‘๋‘์‚ฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค settings. ์ด๋ฆ„์€ ๋ฌด์—‡์ด๋“  ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์—์„œ ๊ฐ€์ ธ์˜จ ๊ฒƒ์ž…๋‹ˆ๋‹ค settings.xml. ์˜ˆ:

${settings.localRepository} sets the path to the local repository.
์ฝ”๋ฉ˜ํŠธ
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION