헤르메스 LIFE

[Spring Boot] 개발환경 구축 - Hello Thymeleaf 본문

Spring Boot Framework

[Spring Boot] 개발환경 구축 - Hello Thymeleaf

헤르메스의날개 2023. 1. 29. 21:09
728x90

SimpleSpringBoot.zip
0.07MB

개발환경

1. STS 버전 : 4.13.1

2. JDK 버전 : OpenJDK 11.0.14_9_x64

3. Tomcat 버전 : 9.0.71

4. Maven 버전 : 3.8.4

5. Spring 버전 : Spring Boot 2.7.8

6. Thymeleaf 3.0.15


pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.7.8</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>simple.spring</groupId>
	<artifactId>SimpleSpringBoot</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>SimpleSpringBoot</name>
	<description>Simple Spring Boot Project</description>
	<properties>
		<java.version>11</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-jdbc</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.mybatis.spring.boot</groupId>
			<artifactId>mybatis-spring-boot-starter</artifactId>
			<version>2.3.0</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<scope>runtime</scope>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<optional>true</optional>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
				<configuration>
					<excludes>
						<exclude>
							<groupId>org.projectlombok</groupId>
							<artifactId>lombok</artifactId>
						</exclude>
					</excludes>
				</configuration>
			</plugin>
		</plugins>
	</build>

</project>

application.properties

#Server port
server.port=8081
server.servlet.context-path=/
#
server.servlet.encoding.enabled=true
server.servlet.encoding.charset=UTF-8
server.servlet.encoding.force=true
# 기본단위 : 초
server.servlet.session.timeout=120
# Spring Default : UTF-8
server.tomcat.uri-encoding=UTF-8
#
spring.thymeleaf.cache=false

logback.xml - 파일명칭이 동일해야 아래의 설정이 적용됩니다.

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
    <!-- 로그 파일이 저장될 경로 -->
    <property name="LOG_PATH" value="C:/greenhorn/logs" />
    <!--로그 파일 저장 위치 -->
    <property name="LOG_FILE_DEV" value="logback-dev#1" />
    <property name="LOG_FILE_PRD" value="logback-prd#1" />

    <!-- pattern -->
    <property name="LOG_PATTERN" value="%-5level %d{yy-MM-dd HH:mm:SSS}[%thread] %logger[%method:%line] - %msg%n" />

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${LOG_PATTERN}</pattern>
        </encoder>
    </appender>
    <appender name="ROLLING-FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${LOG_PATH}/${LOG_FILE_DEV}.log</file>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>${LOG_PATTERN}</pattern>
            <charset>UTF-8</charset>
        </encoder>
        <!-- Rolling 정책 -->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- .gz,.zip 등을 넣으면 자동 일자별 로그파일 압축 -->
            <fileNamePattern>${LOG_PATH}/${LOG_FILE_DEV}.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy
                class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                <!-- 파일당 최고 용량 kb, mb, gb -->
                <maxFileSize>100MB</maxFileSize>
            </timeBasedFileNamingAndTriggeringPolicy>
            <!-- 일자별 로그파일 최대 보관주기(~일), 해당 설정일 이상된 파일은 자동으로 제거 -->
            <maxHistory>30</maxHistory>
        </rollingPolicy>
    </appender>

    <logger name="simple" level="debug" additivity="false">
        <!-- ref="appender name 지정" -->
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="ROLLING-FILE" />
    </logger>
    <root level="debug">
        <appender-ref ref="CONSOLE" />
        <appender-ref ref="ROLLING-FILE" />
    </root>

</configuration>

https://hermeslog.tistory.com/588

 

[Spring Boot] Spring Boot + Thymeleaf

개발환경 1. STS 버전 : 4.13.1 2. JDK 버전 : OpenJDK 11.0.14_9_x64 3. Tomcat 버전 : 9.0.56 4. Maven 버전 : 3.8.4 5. Spring 버전 : Spring Boot 2.6.3 6. Database : Docker 에 DB 설치 - primary - PostgreSQL 13.3 7. Spring Security : 5.6.1 8. lo

hermeslog.tistory.com

https://hermeslog.tistory.com/648

 

[Spring] 개발환경 구축 - Logback

Spring 개발환경을 갑자기 구축하려고 하다보니, 막막합니다. 하나 하나 구축해 보겠습니다 개발환경 Spring 4.3.30.RELEASE MAVEN 3.8.4 Logback 1.2.9 pom.xml 4.0.0 SimpleSpring4 SimpleSpring4 0.0.1-SNAPSHOT war SimpleSpring4

hermeslog.tistory.com

 

728x90