[Spring Rest API #2] 인텔리제이(IntelliJ)에서 스프링 REST API 프로젝트 시작하기

2021. 3. 26. 02:12 Spring Data/Spring Data REST

 

| 스프링 REST API 프로젝트 설정

 

인텔리제이에서 스프링 REST API를 시작하기 위해서는 다음 링크를 참고하여 인텔리제이에서 스프링 부트 프로젝트 설정을 완료해야 합니다.

 

[Spring Framework/Spring boot2] - [Spring Boot #1] 인텔리제이(IntelliJ)로 스프링 부트 프로젝트 시작하기

 

 

| 스프링 REST API 프로젝트 구조 

 

프로젝트 구조

\---src
+---main
|   +---java
|   |   \---com
|   |       \---example
|   |           \---springrestapi
|   |                   SpringRestApiApplication.java
|   |
|   \---resources
|       |   application.properties
|       |
|       +---static
|       \---templates
\---test
    \---java
        \---com
            \---example
                \---springrestapi
                    SpringRestApiApplicationTests.java

 

의존성 관리

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.modelmapper</groupId>
        <artifactId>modelmapper</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.restdocs</groupId>
        <artifactId>spring-restdocs-mockmvc</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

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

 

소스 코드

package com.example.springrestapi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringRestApiApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringRestApiApplication.class, args);
    }

}

 

결과 화면

.   ____          _            __ _ _
/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
'  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v2.1.5.RELEASE)

2019-05-25 20:20:34.055  INFO 3248 --- [           main] c.e.s.SpringRestApiApplication           : Starting SpringRestApiApplication on USER-PC with PID 3248 (C:\Users\user\Desktop\Spring-Boot-Community-Rest\spring-rest-api\target\classes started by user in C:\Users\user\Desktop\Spring-Boot-Community-Rest\spring-rest-api)
2019-05-25 20:20:34.059  INFO 3248 --- [           main] c.e.s.SpringRestApiApplication           : No active profile set, falling back to default profiles: default
2019-05-25 20:20:35.796  INFO 3248 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-05-25 20:20:35.832  INFO 3248 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 29ms. Found 0 repository interfaces.
2019-05-25 20:20:36.416  INFO 3248 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$c3cdaca4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-05-25 20:20:36.494  INFO 3248 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$434df9d6] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-05-25 20:20:36.864  INFO 3248 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-05-25 20:20:36.902  INFO 3248 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-05-25 20:20:36.902  INFO 3248 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.19]
2019-05-25 20:20:37.142  INFO 3248 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-05-25 20:20:37.142  INFO 3248 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2959 ms
2019-05-25 20:20:37.462  INFO 3248 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2019-05-25 20:20:37.681  INFO 3248 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2019-05-25 20:20:37.772  INFO 3248 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-05-25 20:20:37.911  INFO 3248 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.10.Final}
2019-05-25 20:20:37.912  INFO 3248 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2019-05-25 20:20:38.227  INFO 3248 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-05-25 20:20:38.456  INFO 3248 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2019-05-25 20:20:38.810  INFO 3248 --- [           main] o.h.t.schema.internal.SchemaCreatorImpl  : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@57a667c8'
2019-05-25 20:20:38.814  INFO 3248 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-05-25 20:20:39.347  INFO 3248 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-05-25 20:20:39.396  WARN 3248 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2019-05-25 20:20:39.715  INFO 3248 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2019-05-25 20:20:39.727  INFO 3248 --- [           main] c.e.s.SpringRestApiApplication           : Started SpringRestApiApplication in 6.425 seconds (JVM running for 8.276)

 

 

참조: https://www.inflearn.com/course/spring_rest-api/#



출처: https://engkimbs.tistory.com/856?category=789178 [새로비]