프로젝트 셋업

SpringBoot를 사용하여 프로젝트를 진행하고자 새로운 프로젝트를 생성하고자 한다. 필자는 spring initializr를 사용했다.

Spring Initializr란??
- SpringBoot를 기반으로 프로젝트를 생성해주는 사이트이다.
- 프로젝트를 보다 쉽게 생성할 수 있게 도와준다.
> Spring Initializr<

 

위의 링크에 들어가면 아래와 같은 사이트가 나올것이다. (필자가 원하는 대로 선택, 기입한 상태이다.)

Spring Initializr

Project: SpringBoot를 빌드하고 배포하는 방식이다.
Language: 사용하고자하는 언어를 선택하면 된다.
Spring Boot: 원하는 버전을 선택하면 된다. (SNAPSHOT은 데모버전. 버전이 높을수록 레퍼런스가 적다.)

<Project Metadata>
Group: 프로젝트의 도메인명을 기재한다.
Artifact: 빌드되어 나올 결과물의 이름이다.
Name: 프로젝트 명을 기재한다. (일반적으로 Artifact와 동일하게 적용)
Description: 프로젝트에 대한 설명을 기재한다.
Package Name: 패키지의 이름을 기재한다. (이는 Group과 Artifact를 기재하면 자동으로 생성된다.)
Packaging: 기본적으로 Java -jar를 이용해 생성된 압축(아카이브) 파일이다. 원하는걸 선택해주면 된다.
 * Jar(Java Archive): Java 어플리케이션이 동작할 수 있도록 자바 프로젝트를 압축한 파일
 * War (Web Application Archive): 웹 어플리케이션 전체를 패키징 하기 위한 Jar 파일 

<Dependencies>
프로젝트에 사용될 라이브러리들을 선택해주면 프로젝트 생성과 동시에 의존성 주입을 해준다.
필자는 lombok, Mybatis Framework, Oracle Driver, Spring Security, JDBC API 를 선택해주었다.

 

1. 선택과 기재를 완료한 뒤, GENERATE 버튼을 눌러 프로젝트를 생성한다.

2. 다운로드된 파일의 압축을 해제하고 인텔리제이를 열어 우측상단에 Open 버튼을 클릭한다.

3. 합축 해제한 경로에 있는 build.gradle을 Open as Project를 이용해 열어준다.

 

 

WARN 12472 로그발생 (Spring Security 관련)

프로젝트가 열렸으면 우측 하단에 의존성 주입 및 라이브러리들이 설치되는것을 기다렸다가 (게이지가 차면서 다운로드되는것이 보인다) SpringbootApplication 어노테이션이 있는 클래스를 Run 해주고, 크롬을 열어 도메인에 localhost:8080을 입력하면 로그인 페이지로 이동하면서 콘솔창에 2줄의 로그가 발생된다. 

 

로그인 페이지가 보인다...
2줄의 로그...

⚫️ Using generated security password: 7e0f48eb-76d8-4421-abd4-59b5631f526e

    -> Spring Security에서 제공하는 가장 기본적인 인증이 적용되었고, 그 인증에 대한 암호이다.

    -> 기본인증 ID: user

 

⚫️ This generated password is for development use only. Your security configuration must be updated before running your application in production.

    -> WARN 12472: UserDetailsServiceAutoConfiguration 파일과 연관이 있는 로그다.

    -> UserDetailsServiceAutoConfiguration 클래스는 SpringBoot에서 제공하는 자동 설정 파일이다.

package org.springframework.boot.autoconfigure.security.servlet;

@AutoConfiguration
@ConditionalOnClass({AuthenticationManager.class})
@Conditional({MissingAlternativeOrUserPropertiesConfigured.class})
@ConditionalOnBean({ObjectPostProcessor.class})
@ConditionalOnMissingBean(
    value = {AuthenticationManager.class, AuthenticationProvider.class, UserDetailsService.class, AuthenticationManagerResolver.class},
    type = {"org.springframework.security.oauth2.jwt.JwtDecoder"}
)

   

 

로그... 너무 거슬린다... 

    -> 프로젝트 생성과 동시에 의존성 주입만 완료했을뿐 추가적인 설정은 없기에 어노테이션에 명시되어있는 클래스가 Bean으로 등록되어 있지 않기에 로그가 뜨는것으로 추측된다.

    -> 추후 Jason Web Token(JWT) 사용할 때 설정할 예정이므로 Spring Security 의존성을 주석처리했다.

 

Spring Security 의존성 주석처리

 

이후 다시 SpringbootApplication 어노테이션이 있는 클래스를 Run 해주면....

아래와 같이 로그가 쌓이면서 서버가 실행되고, Application이 실행되는것을 확인할 수 있다.

/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java -XX:TieredStopAtLevel=1 -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dmanagement.endpoints.jmx.exposure.include=* -javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=57565:/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Users/keem/finalProject/vibevillage/build/classes/java/main:/Users/keem/finalProject/vibevillage/build/resources/main:/Users/keem/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.34/ec547ef414ab1d2c040118fb9c1c265ada63af14/lombok-1.18.34.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.mybatis.spring.boot/mybatis-spring-boot-starter/3.0.3/19528356bf8bad2be5f8bf796dfc30bcc4996054/mybatis-spring-boot-starter-3.0.3.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-jdbc/3.2.8/2f22137b97a39c8025d97e5b777fca83824f9888/spring-boot-starter-jdbc-3.2.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-web/3.2.8/8dd35c1f7c7bbffc391f68b9e27ea77ad4d8c0c6/spring-boot-starter-web-3.2.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter/3.2.8/8dd4d2ffb32d67c975d8cacfe0d8a3edbf2040ee/spring-boot-starter-3.2.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.mybatis.spring.boot/mybatis-spring-boot-autoconfigure/3.0.3/b73a2effa4f60a2eeca98aa12ea3437faede0f73/mybatis-spring-boot-autoconfigure-3.0.3.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.mybatis/mybatis/3.5.14/d94d2267d1caf1c31748123e671dcea5ad1a6f8/mybatis-3.5.14.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.mybatis/mybatis-spring/3.0.3/5a4ab31bfb62bca615b39ade93de2a607e9b9403/mybatis-spring-3.0.3.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/com.zaxxer/HikariCP/5.0.1/a74c7f0a37046846e88d54f7cb6ea6d565c65f9c/HikariCP-5.0.1.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jdbc/6.1.11/92b9f712206993c56c56903547c6b695a4a70128/spring-jdbc-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-json/3.2.8/4bc4051954d373a3ad3eb0395495cd244801edb/spring-boot-starter-json-3.2.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-tomcat/3.2.8/d2e1a76690ba18344f0921ee5ad507bc96fef8d6/spring-boot-starter-tomcat-3.2.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-webmvc/6.1.11/9ec4c2a5e28bf7b2d60e254e976940b12c8ba32a/spring-webmvc-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-web/6.1.11/8910d08f15492273543d2c8032b2b895e08ed9e/spring-web-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/3.2.8/dde5fc7d47693b68ccff343b498f3485ffe49ff0/spring-boot-autoconfigure-3.2.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/3.2.8/c1724848953d313c9478587a29c07b76bbe80326/spring-boot-3.2.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-logging/3.2.8/f3365834f85b2495c9a29ce1745c86390caed79a/spring-boot-starter-logging-3.2.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/jakarta.annotation/jakarta.annotation-api/2.1.1/48b9bda22b091b1f48b13af03fe36db3be6e1ae3/jakarta.annotation-api-2.1.1.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/6.1.11/90fce4311852c68c1e87c65adf60db9add1a6dcb/spring-core-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.yaml/snakeyaml/2.2/3af797a25458550a16bf89acc8e4ab2b7f2bfce0/snakeyaml-2.2.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/2.0.13/80229737f704b121a318bba5d5deacbcf395bc77/slf4j-api-2.0.13.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-tx/6.1.11/2e38b3218ae80d0b5401a4ef299c4cfbc3a73ed7/spring-tx-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/6.1.11/266176d132ab2bbf8e69e4aa6d7f47ec746ddc9a/spring-beans-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.15.4/7de629770a4559db57128d35ccae7d2fddd35db3/jackson-datatype-jsr310-2.15.4.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.module/jackson-module-parameter-names/2.15.4/e654497a08359db2521b69b5f710e00836915d8c/jackson-module-parameter-names-2.15.4.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.15.4/694777f182334a21bf1aeab1b04cc4398c801f3f/jackson-datatype-jdk8-2.15.4.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.15.4/560309fc381f77d4d15c4a4cdaa0db5025c4fd13/jackson-databind-2.15.4.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-websocket/10.1.26/3b147d7e5566e9361e86422f9e49fdd56a429637/tomcat-embed-websocket-10.1.26.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-core/10.1.26/5e0fa06ca373ef0ca55e603291ea51b590c377ea/tomcat-embed-core-10.1.26.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-el/10.1.26/5a5cbcb3e51fcd557b164736e9920a3dd2ac1e33/tomcat-embed-el-10.1.26.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/6.1.11/8fc69f776333713aa26be8821af8c6355ccad8d8/spring-context-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/6.1.11/3503ef99b759b81f8b0b3d5260bf4842e393a581/spring-aop-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/6.1.11/7c12cf1cd39289cfab7c5933eda9e4704a7f2799/spring-expression-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/io.micrometer/micrometer-observation/1.12.8/33e6ba3ca270e66b9c6145585f62f53f7e651fae/micrometer-observation-1.12.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.4.14/d98bc162275134cdf1518774da4a2a17ef6fb94d/logback-classic-1.4.14.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-to-slf4j/2.21.1/d77b2ba81711ed596cd797cc2b5b5bd7409d841c/log4j-to-slf4j-2.21.1.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.slf4j/jul-to-slf4j/2.0.13/a3bcd9d9dd50c71ce69f06b1fd05e40fdeff6ba5/jul-to-slf4j-2.0.13.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.springframework/spring-jcl/6.1.11/97b34c6b72c8084759e71cd09a7dad16bfb8f1da/spring-jcl-6.1.11.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.15.4/5223ea5a9bf52cdc9c5e537a0e52f2432eaf208b/jackson-annotations-2.15.4.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.15.4/aebe84b45360debad94f692a4074c6aceb535fa0/jackson-core-2.15.4.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/io.micrometer/micrometer-commons/1.12.8/5683b9834ddb02244076a5acc404c9aed0adf8ee/micrometer-commons-1.12.8.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.4.14/4d3c2248219ac0effeb380ed4c5280a80bf395e8/logback-core-1.4.14.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.21.1/74c65e87b9ce1694a01524e192d7be989ba70486/log4j-api-2.21.1.jar:/Users/keem/.gradle/caches/modules-2/files-2.1/com.oracle.database.jdbc/ojdbc11/21.9.0.0/1aad2e20684ee075bb9ebdca2d83f028e4fd35fa/ojdbc11-21.9.0.0.jar kr.co.vibevillage.VibevillageApplication

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.8)

2024-07-25T23:02:02.952+09:00  INFO 46526 --- [vibevillage] [           main] k.co.vibevillage.VibevillageApplication  : Starting VibevillageApplication using Java 17.0.12 with PID 46526 (/Users/keem/finalProject/vibevillage/build/classes/java/main started by keem in /Users/keem/finalProject/vibevillage)
2024-07-25T23:02:02.953+09:00  INFO 46526 --- [vibevillage] [           main] k.co.vibevillage.VibevillageApplication  : No active profile set, falling back to 1 default profile: "default"
2024-07-25T23:02:03.383+09:00  INFO 46526 --- [vibevillage] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2024-07-25T23:02:03.388+09:00  INFO 46526 --- [vibevillage] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-07-25T23:02:03.389+09:00  INFO 46526 --- [vibevillage] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.26]
2024-07-25T23:02:03.409+09:00  INFO 46526 --- [vibevillage] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-07-25T23:02:03.409+09:00  INFO 46526 --- [vibevillage] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 440 ms
2024-07-25T23:02:03.759+09:00  INFO 46526 --- [vibevillage] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''
2024-07-25T23:02:03.766+09:00  INFO 46526 --- [vibevillage] [           main] k.co.vibevillage.VibevillageApplication  : Started VibevillageApplication in 0.984 seconds (process running for 1.21)

localhost:8080

 

 

다음 포스팅에는 mybatis를 이용한 DataBase연결에 대해 작성해보겠다.

김현중 (keemhing)