Spring νλ‘μ νΈλ₯Ό λ§λ€ λ Typeμ MavenμΌλ‘ μ€μ νλ€.
κ·Έλ λ€λ©΄ Mavenμ λκΉ?
Maven
Mavenμ νλ‘μ νΈλ₯Ό κ΄λ¦¬νκ³ λΉλμ λμμ μ£Όλ λꡬμ΄λ€.
κ·Έλ¦¬κ³ Mavenμ νλ μμν¬μ΄λ€.
(νλ μμν¬λΌ μ ν΄μ§ λμ λ°©μμ΄ μλ€.(LifeCycle)
LifeCycleμ λν λ΄μ©μ μΆν λ€λ₯Έ κ²μκΈμμ λ€λ£¨λλ‘ νκ² λ€.)
λΌμ΄λΈλ¬λ¦¬μ νλ μμν¬μ 곡ν΅μ κ³Ό μ°¨μ΄μ
"λ΄κ°" λΌμ΄λΈλ¬λ¦¬λ₯Ό λΆλ₯΄λ κ²μ΄κ³ "νλ μμν¬"κ° λλ₯Ό λΆλ₯΄λ κ²μ΄λ€.
velog.io
μμΈν μ€λͺ μ νκΈ°μ μμ, λΉλμ λν κ°λ μ μ΄ν΄νκ³ μ νλ€.
λΉλλ?
λΉλ : κ°λ°μκ° μμ±ν μμ€μ½λλ₯Ό μ€ν κ°λ₯ν νλ‘κ·Έλ¨μΌλ‘ λ³ννλ λ¨κ³
μ΄λ¬ν λ³νλ νλ‘κ·Έλ¨μ μ¬μ©μκ° μ€ννκ±°λ λ°°ν¬ν μ μλ€.
λΉλ λꡬλ?
μννΈμ¨μ΄ κ°λ° κ³Όμ μμ μμ€ μ½λλ₯Ό μ»΄νμΌνκ³ , μμ‘΄μ±μ κ΄λ¦¬νκ³ , ν μ€νΈ λ° λΉλ νλ‘μΈμ€λ₯Ό μλννλ λꡬμ΄λ€.
μ΄ λꡬλ₯Ό μ¬μ©νλ©΄ λ ν¨μ¨μ μΌλ‘ νλ‘μ νΈλ₯Ό λΉλνκ³ κ΄λ¦¬ν μ μλ€.
μλ₯Όλ€μ΄ Maven, Gradle, Antκ° μλ€.
Maven
λ€μ MavenμΌλ‘ λμμ보μ.
Mavenμ νλ‘μ νΈλ₯Ό κ΄λ¦¬ν΄μ£Όκ³ λΉλν΄μ£Όλ λꡬμ΄λ€.
Maven νλ‘μ νΈ κ΅¬μ‘°
my-project/
|-- src/
| |-- main/
| | |-- java/ # Java μμ€ μ½λ
| | |-- resources/ # 리μμ€ νμΌ (νλ‘νΌν°, μ€μ νμΌ λ±)
| |-- test/
| |-- java/ # ν
μ€νΈμ© Java μμ€ μ½λ
| |-- resources/ # ν
μ€νΈ 리μμ€ νμΌ
|-- target/ # λΉλ κ²°κ³Όλ¬Ό μ μ₯ ν΄λ
|-- pom.xml # νλ‘μ νΈ μ€μ νμΌ
Maven νλ‘μ νΈ κ΅¬μ‘°λ μμ κ°μ΄ λμ΄ μλ€.
κ·Έλ λ€λ©΄ μ΄ λκ΅¬κ° μ νμν΄μ‘μκΉ? μ΄ λκ΅¬κ° μ λ§λ€μ΄μ‘μκΉ?
βκΆκΈμ¦β
βΆοΈ μ°λ¦¬λ μ΄λ€ νλ‘μ νΈλ₯Ό κ°λ°ν λ λͺ¨λ μ½λλ₯Ό μ§μ λ€ μμ±νμ§ μλλ€.
κΈ°μ‘΄μ μλ λΌμ΄λΈλ¬λ¦¬λ₯Ό κ°μ Έμ μ¬μ©νλ€.
μλ₯Ό λ€μ΄ μ°λ¦¬κ° μ¬μ©ν λΌμ΄λΈλ¬λ¦¬κ° ν κ°λΌλ©΄ κ΄λ¦¬νκΈ° μ¬μΈ κ²μ΄λ€.
νμ§λ§ μ¬μ©ν λΌμ΄λΈλ¬λ¦¬κ° μμ κ°κ° λλ€λ©΄? λΌμ΄λΈλ¬λ¦¬λ₯Ό κ΄λ¦¬νκΈ° μ΄λ €μμ§ κ²μ΄λ€.
(λ²μ κ΄λ¦¬, λ€μ΄λ‘λ κ΄λ¦¬ λ±λ±)
κ·Έλμ μ΄ λΌμ΄λΈλ¬λ¦¬λ₯Ό κ΄λ¦¬ν΄ μ€ Maven λκ΅¬κ° λ±μ₯ν κ²μ΄λ€.
Mavenμ pom.xmlμ΄ μλλ° pom.xml νμΌμ νμν λΌμ΄λΈλ¬λ¦¬λ€μ 미리 μ€μ ν΄λλ©΄,
Mavenμ΄ νμν λΌμ΄λΈλ¬λ¦¬λ₯Ό λ€νΈμν¬λ₯Ό ν΅ν΄μ λ€μ΄λ‘λν΄ μ€λ€.
κ·Έλ λ€λ©΄, pom.xmlμ΄λ?
pom.xml (Proejct Object Model)
Maven κΈ°λ° νλ‘μ νΈμμ μ¬μ©νλ μ€μ νμΌ.
νλ‘μ νΈμ μ 보, μμ‘΄μ± κ΄λ¦¬, λΉλ μ€μ λ±μ XML νμμΌλ‘ μ μνλ νμΌ
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>springapp1-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>springapp1-1</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
μλ μμ μ spring boot μ²μ λ°°μΈ λ λ§λ νλ‘μ νΈμ pom.xmlμ΄λ€.
λ€μ ꡬ쑰λ₯Ό μ 리νμλ©΄ μ΄λ κ² λλ€.
<?xml version="1.0" encoding="UTF-8"?>
<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">
<!-- νλ‘μ νΈ μ 보 -->
<groupId>com.example</groupId>
<artifactId>my-project</artifactId>
<version>1.0.0</version>
<!-- μμ‘΄μ± κ΄λ¦¬ -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.9</version>
</dependency>
<!-- ... λ€λ₯Έ μμ‘΄μ± ... -->
</dependencies>
<!-- νλ¬κ·ΈμΈ μ€μ -->
<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>
<!-- ... λ€λ₯Έ μ€μ ... -->
</project>
<modelVersion></modelVersion>
Mvenμ λͺ¨λΈ λ²μ μ μλ―Ένλ€.
μ¦, pom.xmlμ λ²μ μ΄λΌκ³ μκ°νλ©΄ λλ€.
<groupId></groupId>
μλ³ν μ μλ IDλ₯Ό μ§μ νλ κ³³
νλ‘μ νΈλ₯Ό μμ±ν κ·Έλ£Ήλͺ μΌλ‘ μ μμμ νμ¬, λ¨μ²΄ λ±μ μλ³νκΈ° μν κ².
<artifactId></artifactId>
μ΄ νλ‘μ νΈμ κ³ μ IDλ₯Ό μλ―Ένλ€.
μλ¬Έμλ‘λ§ μμ±ν΄μΌ νλ€.
<version></version>
νλ‘κ·Έλ¨μ λ²μ μ μλ―Ένλ€.
<packaging></packaging>
ν¨ν€μ§ μ’ λ₯λ₯Ό μ€μ νλ κ³³
λ³΄ν΅ zip, jar, warλ‘ μ€μ νλ€.
<name></name>
νλ‘μ νΈμ μ΄λ¦μ μ€μ νλ κ³³
<dependencies></dependencies>
μ΄ νκ·Έ μμ μ¬λ¬ κ°μ <dependency></dependency>λ₯Ό μ μνλλ°, μ΄ <dependency>λ₯Ό λ¬Άμ΄μ£Όλ νκ·ΈλΌκ³ ν μ μλ€.
<dependency></dependency>
νλ‘μ νΈμ μμ‘΄κ΄κ³μ μλ λΌμ΄λΈλ¬λ¦¬λ₯Ό μ€μ νμ¬ λ±λ‘νλ νκ·Έμ΄λ€.
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.5</version>
<scope>runtime</scope>
</dependency>
<scope></scope>
λΌμ΄λΈλ¬λ¦¬κ° μ΄μ©λλ λ²μλ₯Ό μ§μ νλ κ².
μ xmlμ μλ₯Ό λ€λ©΄, runtime ν λλ§ μ¬μ©νκ² λ€κ³ μ§μ ν κ²μ΄λ€.
<profiles></profiles>
μ΄ νκ·Έλ <profile>νκ·Έλ₯Ό λ¬Άμ΄μ£Όλ μν μ νλ€.
<profile></profile>
νλ‘μ νΈλ₯Ό λ‘컬 / κ°λ° / μ΄μμ λ°λΌμ pon.xmlμ urlμ μ€μ ν μ μλλ‘ ν΄μ£Όλ κ³³μ΄λ€.
μ°Έμ‘°ν κΈ
https://goddaehee.tistory.com/199
[Maven] Maven μ΄λ? (μ μ, μμ )
[Maven] λ©μ΄λΈ μ΄λ? (μ μ, μμ ) μλ νμΈμ. κ°λν¬ μ λλ€. μ΄λ² ν¬μ€ν μ [ λ©μ΄λΈ μμ보기 ] μ λλ€. : ) 1. λΉλ (Build) #1 λΉλλ? - μμ€μ½λ νμΌμ μ»΄ν¨ν°μμ μ€νν μ μλ λ 립 μννΈμ¨
goddaehee.tistory.com
[μ€νλ§(Spring)] pom.xmlμ ꡬ쑰
pom.xmlμ Maven ꡬ쑰μμ Mavenμ μ€μ μ ν μ μλ κ³³μ΄λ©΄μ, λ€μν λΌμ΄λΈλ¬λ¦¬μ νλ μμν¬λ₯Ό μ¬μ©ν μ μλλ‘ Mavenμ΄ κ΄λ¦¬λ₯Ό νλ€. κ·Έλμ, pom.xmlμ μ΄ Mavenμ λΉλν μ μλλ‘ μ€μ νλ λΉλ
yongku.tistory.com
'πΉπππ > ππππππ π±πππ' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[SpringBoot] application.properties μ΄μ체μ λ³ μ€μ (0) | 2024.11.20 |
---|---|
Spring Bootλ? / STS4 μ€μΉ (1) | 2023.05.15 |