springboot
Spring-Boot 환경설정
전주천둥새
2023. 5. 15. 16:28
1. 새로운 작업환경설정
- 작업 폴더생성
- UTF-8로 환경 설정

- html 템플릿 수정

- thymeleaf플러그인 설치
help > install new software > work with 부분에 플러그인 주소입력
(http://www.thymeleaf.org/eclipse-plugin-update-site/) > 라이센스 허용 > install anyway > restart
2. 파일생성


- 기존 작업파일의 해당 폴더 복사해오기

> thymeleaf layout dialect

> 버전선택
> Maven 의존성 스크립트 코드 복사

> pom.xml의 dependencies 내부에 해당 코드 삽입 (버전 생략시 최신버전으로 자동 다운로드)
<!-- https://mvnrepository.com/artifact/nz.net.ultraq.thymeleaf/thymeleaf-layout-dialect -->
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>
</dependencies>
2) log4j 사용하기(프로젝트 의존성 추가)
> pom.xml의 dependencies 내부에 해당 코드 삽입
<!-- https://mvnrepository.com/artifact/org.bgee.log4jdbc-log4j2/log4jdbc-log4j2-jdbc4.1 -->
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
<version>1.16</version>
</dependency>
</dependencies>
- application.properties 설정
#server port 설정
server.port=80
#thymeleaf 새로고침 여부
spring.thymeleaf.cache=false
# DB 연결정보 설정
spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/ksmart43db?serverTimezone=UTC&characterEncoding=UTF8
spring.datasource.username=ksmart43id
spring.datasource.password=ksmart43pw
3. MainController 생성 및 동작 확인

package com.test.mybatis.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class MainController {
/*
* 메인화면 index
* @return index.html 논리적경로
*/
@GetMapping("/")
public String index() {
return "index";
}
}
> run as 동작확인
