[Spring boot 토이프로젝트] 프로젝트 시작하기

Yu River·2022년 7월 18일
0

참고 공식문서

[1] Maven

(1) maven 프로젝트 생성





더블클릭해서 1.8로 바꿔준다.

? Java Build Path 오류

Select the fix for 'Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment. '.

pom.xml

<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>
  <groupId>me.yuha</groupId>
  <artifactId>spring-boot-getting-started</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</project>

(2) maven auto enable 설정하기


(3) Parent POM 설정

  • 메이븐 간의 프로젝트는 계층 구조가 가능하다.
  • 해당 메이븐 프로젝트의 부모 프로젝트를 spring-boot-starter-parent로 지정해주었다.
  • 이는 스프링 부트의 가장 큰 특징 중 하나인 의존성 관리의 모습을 보여준다.
<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>
  <groupId>me.yuha</groupId>
  <artifactId>spring-boot-getting-started</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <!-- Inherit defaults from Spring Boot -->
<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.7.1</version>
</parent>

</project>

(4) 기타 의존성 추가

1. spring-boot-starter-web 추가,spring-boot-starter-test 추가

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

pom.xml

<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>
  <groupId>me.yuha</groupId>
  <artifactId>spring-boot-getting-started</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
  <!-- Inherit defaults from Spring Boot -->
<parent>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-parent</artifactId>
	<version>2.7.1</version>
</parent>

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

</project>

(4) The “autoconfigure” Module

maven build plug in 추가

        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

gradle 4.5이상 추가

난 6.5를 사용하니깐...

dependencies {
    annotationProcessor "org.springframework.boot:spring-boot-autoconfigure-processor"
}
profile
도광양회(韜光養晦) ‘빛을 감추고 어둠속에서 힘을 기른다’

0개의 댓글