[Spring] Spring 환경 IntelliJ에 구축

IntelliJ 다운로드

 

https://www.jetbrains.com/ko-kr/idea/download/#section=windows

(위의 사이트에서 다운로드 진행)

원하는 것으로 다운로드 진행하면 되나 무료 버전인 Community Edition 으로 다운로드 함


Spring 환경설정

 

1. Spring Initializr 이용하기

https://start.spring.io/

사이트에서 원하는 버전과 프로젝트 명을 지정하고 다운로드한다.

 

2. IntelliJ에서 폴더 열기

1번에서 다운받은 폴더의 압축을 해지한 경로를 확인하고

IntelliJ에서 열어준다.

위의 사진처럼 빌드되지 않는다면 1번 단계에서 Spring Boot 의 버전을 2.7.7로 바꿔보시는걸 추천드립니다

 


추가정보

1. application.yml 파일과 application.propertier 파일 차이

해당 파일은 프로젝트 폴더의 src > main > resources 폴더 안에 위치한다.

두 파일의 차이는 아래와 같다. 편한 방법으로 사용하면 된다. (yml 추천)

<yml>

spring:
  jpa:
    properties:
      hibernate:
        format_sql: true
        ddl-auto: create

<propertier>

spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=false

2. build.gradle 파일에 의존성 추가

https://mvnrepository.com/


위 사이트에 접속하여 추가하고자 하는 것을 검색한다.


원하는 버전을 클릭하고


Gradle 클릭하고 해당 내용을 복사해서 붙여넣으면 사용할 수 있다.


<ex>

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'
// https://mvnrepository.com/artifact/org.projectlombok/lombok
	compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.24'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa
	implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.7.7'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-jdbc
	implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '2.7.7'
// https://mvnrepository.com/artifact/org.postgresql/postgresql
	implementation group: 'org.postgresql', name: 'postgresql', version: '42.5.1'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
	implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.7.7'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-amqp
	implementation group: 'org.springframework.boot', name: 'spring-boot-starter-amqp', version: '2.7.7'
	implementation 'com.rabbitmq:amqp-client:5.16.0'
	// https://mvnrepository.com/artifact/com.google.code.gson/gson
	implementation group: 'com.google.code.gson', name: 'gson', version: '2.10'
}