๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Spring

์Šคํ”„๋ง ๋ถ€ํŠธ์˜ ์˜์กด์„ฑ ๊ด€๋ฆฌ(Dependency Management)

by Leica 2020. 3. 11.
๋ฐ˜์‘ํ˜•

์Šคํ”„๋ง ๋ถ€ํŠธ์˜ ์˜์กด์„ฑ ๊ด€๋ฆฌ(Dependency Management)

๊ธฐ๋ณธ์ ์ธ ์Šคํ”„๋ง ๋ถ€ํŠธ ํ”„๋กœ์ ํŠธ์˜ pom.xml ํŒŒ์ผ์„ ๋ณด๋ฉด ์˜์กด์„ฑ ์„ค์ •์ด spring-boot-starter-web๊ณผ spring-boot-starter-test ๋‘ ๊ฐœ ๋ฟ์ด๊ณ  ๋ฒ„์ „ ๋˜ํ•œ ๋ช…์‹œํ•˜์ง€ ์•Š๊ณ  ์žˆ์ง€๋งŒ ์ˆ˜ ๋งŽ์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์„ ์•Œ์•„์„œ ๊ฐ€์ ธ์˜จ๋‹ค.

 

<dependencies>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-web</artifactId>
	</dependency>

	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-test</artifactId>
		<scope>test</scope>
		<exclusions>
			<exclusion>
				<groupId>org.junit.vintage</groupId>
				<artifactId>junit-vintage-engine</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
</dependencies>

 

 

์ด๊ฒƒ์ด ๊ฐ€๋Šฅํ•œ ์ด์œ ๋Š” ์Šคํ”„๋ง ๋ถ€ํŠธ๊ฐ€ ์ œ๊ณตํ•˜๋Š” ์˜์กด์„ฑ ๊ด€๋ฆฌ ๊ธฐ๋Šฅ ๋•Œ๋ฌธ์ด๋‹ค.

 

๊ธฐ๋ณธ ์Šคํ”„๋ง ๋ถ€ํŠธ ํ”„๋กœ์ ํŠธ๋Š” spring-boot-starter-parent๊ฐ€ parent pom์œผ๋กœ ์„ค์ •๋˜์–ด ์žˆ๋‹ค.

<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.2.5.RELEASE</version>
	<relativePath/> <!-- lookup parent from repository -->
</parent>

 

์ด parent pom์„ ํ™•์ธํ•ด๋ณด๋ฉด spring-boot-dependencies๋ฅผ ๋‹ค์‹œ parent๋กœ ์„ค์ •ํ•˜๊ณ  ์žˆ๋‹ค.

<parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-dependencies</artifactId>
  <version>2.2.5.RELEASE</version>
  <relativePath>../../spring-boot-dependencies</relativePath>
</parent>

 

์ฆ‰ maven pom ์ƒ์† ๊ตฌ์กฐ๊ฐ€ [๊ธฐ๋ณธ ์Šคํ”„๋ง ๋ถ€ํŠธ ํ”„๋กœ์ ํŠธ] - [spring-boot-starter-parent] - [spring-boot-dependencies] ์ˆœ์œผ๋กœ ๋˜์–ด์žˆ๋Š” ๊ฒƒ์ด๋‹ค.

 

์ด ์Šคํ”„๋ง ๋ถ€ํŠธ ํ”„๋กœ์ ํŠธ์˜ ์ตœ์ƒ๋‹จ์— ์žˆ๋Š” spring-boot-dependencies pom์˜ <properties>์™€ <dependencyManagement>์— ๊ฐ€์ ธ์˜ฌ ์˜์กด์„ฑ๊ณผ ๋ฒ„์ „์ด ๋ช…์‹œ๋˜์–ด์žˆ๋‹ค.

๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ์Šคํ”„๋ง ๋ถ€ํŠธ ํ”„๋กœ์ ํŠธ์˜ pom.xml์— ์ง์ ‘ ๋ฒ„์ „์„ ๋ช…์‹œํ•˜์ง€ ์•Š์•„๋„ spring-boot-dependencies์—์„œ ๊ด€๋ฆฌํ•ด์ฃผ๋Š” ๋ฒ„์ „์„ ์•Œ์•„์„œ ๊ฐ€์ ธ์˜ค๊ฒŒ ๋œ๋‹ค.

 

์ฐธ๊ณ ๋กœ IntelliJ์—์„œ๋Š” pom.xml์˜ ์™ผ์ชฝ์— ํ‘œ์‹œ๋˜๋Š” ์•„์ด์ฝ˜์— ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ ค๋ณด๋ฉด ๋ฌด์Šจ ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์•Œ๋ ค์ค€๋‹ค.

 

์Šคํ”„๋ง ๋ถ€ํŠธ๊ฐ€ ์ œ๊ณตํ•ด์ฃผ๋Š” ์˜์กด์„ฑ ๊ด€๋ฆฌ ๊ธฐ๋Šฅ์˜ ์žฅ์ ์€ ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

 

  • ์ง์ ‘ ๊ด€๋ฆฌํ•ด์•ผํ•˜๋Š” ์˜์กด์„ฑ์˜ ์ˆ˜๊ฐ€ ์ค„์–ด๋“ ๋‹ค.
  • ์˜์กด์„ฑ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์˜ ๋ฒ„์ „ ์ถฉ๋Œ ์ด์Šˆ๊ฐ€ ํ•ด๊ฒฐ๋œ๋‹ค.

 

References

์ธํ”„๋Ÿฐ - ๋ฐฑ๊ธฐ์„ ๋‹˜์˜ ์Šคํ”„๋ง ๋ถ€ํŠธ ๊ฐœ๋…๊ณผ ํ™œ์šฉ

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€