> IDE
1. 전용 개발 툴 : STS (Spring Toll Suit)
- Spring initializer 내장
- 이클립스를 기반으로 하는 툴
- 장점: 기본적으로 내장되어있는 기능이 많음
- 단점: 무료, 느림
2. InteliJ
- 유료버전: 빠름, STS에 비해 기능 적음
- 무료버전: start.spring.io 에서 직접 설정 및 다운 필요
InteliJ 개발환경 구축
1. 인텔리제이 다운로드 검색
- community edition (무료버전) 다운 -> [idealC - 2023.1.exe]라는 이름의 폴더로 다운됨
- 설치창에서 createDesktop shorcut 체크하면 바탕화면에 바로가기 생성
- 다른 옵션들은 그냥 넘어가도 무관
2. spring initializr 검색
- Maven > Java > 3.0.5 >Java(20) > Add Dependencies
<Dependencies>
* Spring Boot DevTools (편리한 개발환경 제공)
* Lombok (getter, setter, constructor 등 DTO 관련 기능 제공)
* spring web (web build 시 필요)
* Thymeleaf
* validation
* MySQL Driver
* H2 Database (테스트 시 사용 -> pom.xml에서 scope를 runtime에서 test로 변경할것)
* Spring Data JPA
- Generate 클릭 -> 기본 Maven프로젝트 생성 > 압축 풀기
- intelliJ > Open > 다운받은 프로젝트 열기
3. intelliJ 자동 셋팅
- File > Setting > Editor > General > Auto Import > Java > Add unambiguous imports on the fly 체크
- Editor > File Encodings > Global Encoding, ProjectEncoding: UTF-8로 변경,
Path에서 + 클릭, 해당 프로젝트의 src 추가, Default encoding for properties files: UTF-8로 변경 > Apply 및 OK
- File > Setting > Build, Execution, Deployment > Compiler > Build project automatically 체크
4. Maven Repository에서 의존성 추가 설치
- Thymeleaf Layout Dialect
- ModelMapper : 동일한 getter, seter가 있으면 자동 변환 (커맨드객체 -> 엔티티)
- Querydsl 검색 후 Querydsl JPA Support, Querydsl APT Support 설치
pom.xml에서 <classifier>jakarta</classifier> 추가
- springboot stater security (버전 제거)
- Thymeleaf Extras Springsecurity6 (버전 제거)
- build 내부에 plugin 추가
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
5. application.properties에 설정 추가
# Spring Boot Dev Tool 설정
spring.devtools.livereload.enabled=true
# 타임리프 설정
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=file:src/main/resources/templates/
# 정적자원 경로 설정
spring.resources.static-locations=file:src/main/resources/static/
# Spring Data JPA 설정
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/[스키마이름]
spring.datasource.username=[username]
spring.datasource.password=[password]
# 실행되는 쿼리 콘솔 출력
spring.jpa.properties.hibernate.show_sql=true
# 콘솔 창에 출력되는 쿼리를 가독성 좋게 포맷팅
spring.jpa.properties.hibernate.format_sql=true
# 쿼리에 물음표로 출력되는 바인드 파라미터 출력
logging.level.org.hibernate.type.descriptor.sql=trace
spring.jpa.hibernate.ddl-auto=update
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
++ liveReload: 크롬 확장팩 설치
'JAVA' 카테고리의 다른 글
Redis 구버전에서 살아남기(계속 업데이트) (0) | 2025.02.27 |
---|---|
[servlet] 리스너 & 필터 (0) | 2023.10.24 |
JAVA 8주차 (1) | 2022.12.23 |
JAVA 7주차 (1) | 2022.12.15 |
JAVA 6주차 (0) | 2022.12.11 |
댓글