본문 바로가기
IT/WEB

[41일차] Java Spring Boot

by GWLEE 2022. 8. 18.

🧡2022-08-18🧡

 

starter Project select 

 

logback-spring.xml 만들기

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<property name="LOG_PATH" value="E:/tmp/logs" />

	<appender name="STDOUT"
		class="ch.qos.logback.core.ConsoleAppender">
		<target>System.out</target>
		<encoder>
			<pattern>[%d{yyyy-MM-dd HH:mm:ss}:%-3relative][%thread] [%-5level]
				%logger{35} - %msg%n</pattern>
		</encoder>
	</appender>
	<appender name="ROLLING"
		class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>${LOG_PATH}/logback.log</file>
		<append>true</append>
		<encoder
			class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
			<pattern>[%d{yyyy-MM-dd HH:mm:ss}:%-3relative][%thread] [%-5level]
				%logger{35} - %msg%n</pattern>
		</encoder>
		<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
			<level>INFO</level>
		</filter>
		<rollingPolicy 
			class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
			<fileNamePattern>${LOG_PATH}/logback.%d{yyyy-MM-dd}.%i.log.zip
			</fileNamePattern>
			<maxFileSize>5MB</maxFileSize>
			<maxHistory>30</maxHistory>
		</rollingPolicy> <!-- 롤링 정책 30일 분량의 로그 파일은 유지가 되고 30일 이전의 로그 파일은 삭제-->
	</appender>


	<root level="debug">
		<appender-ref ref="ROLLING" />
		<appender-ref ref="STDOUT" />
	</root>
</configuration>

 

 

WEB-INF 폴더랑 view 폴더 만들기

 

application.properties

#Server
server.port=8090
server.servlet.session.timeout=36000

#Spring MVC
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp

#Database config
spring.datasource.url=jdbc:mysql://localhost:3306/board?useUnicode=true;characterEncoding=utf8;
spring.datasource.username=gyuwon
spring.datasource.password=1234
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver


#Mybatis config
mybatis.config-location=classpath:mybatis-config.xml

#Mybatis mapper
mybatis.mapper-locations=classpath:mapper/article.xml

#Package for using alias in mapper
mybatis.type-aliases-package=com.gyuone.model

 

 

article.xml 이클립스 mapper 그대로 복사

mapper 부분 바꾸기

article.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.gyuone.dao.BoardDao">
	<resultMap type="articleVO" id="articleResult">
		<result property="articleNo" column="ArticleNo" />
		<result property="title" column="Title" />
		<result property="contents" column="Contents" />
		<result property="writeDate" column="WriteDate" />
		<result property="writeId" column="WriteID" />
	</resultMap>
	<select id="selectAllArticles" resultMap="articleResult">
		<![CDATA[
			select * from noticeboard order by WriteDate desc
		]]>
	</select>
	<select id="selectArticle" resultType="articleVO"
		parameterType="int">
		<![CDATA[
			select * from noticeboard where ArticleNo = #{articleNo}
		]]>
	</select>
	<insert id="insertArticle" parameterType="articleVO">
		<![CDATA[
			insert into noticeboard (Title, Contents, WriteDate, WriteID)
			values (#{title}, #{contents}, default, #{writeId})
		]]>
	</insert>
	<update id="updateArticle" parameterType="articleVO">
		<![CDATA[
			update noticeboard set Title=#{title}, Contents=#{contents}, WriteDate=default
			where ArticleNo=#{articleNo}
		]]>
	</update>
	<delete id="deleteArticle" parameterType="int">
		delete from noticeboard
		where ArticleNo=#{articleNo}
	</delete>
</mapper>

 

 

BoardDao.java

package com.gyuone.dao;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.gyuone.model.ArticleVO;

@Mapper
@Repository("boardDao")
public interface BoardDao { // 인터페이스 추상메서드
	// 이클립스에서 mapper와 동일하게 작동 spring이 알아서 찾아감
	public List<ArticleVO> selectAllArticles() throws DataAccessException;
	public ArticleVO selectArticle(int articleNo) throws DataAccessException;
	public void insertArticle(ArticleVO article) throws DataAccessException;
	public void updateArticle(ArticleVO article) throws DataAccessException;
	public void deleteArticle(int articleNo) throws DataAccessException; 
	
}

 

 

jsp파일 아니구 Thymeleaf 사용해서 쓴다.

 

 

1. Thymeleaf -> 미니 프로젝트에서 사용해 볼 것.

2. ORM(JPA)

3. 인증 - 인터셉터, 세션 / Spring Security

4. 부트스트랩 

 

https://ko.javascript.info/async-await

 

async와 await

 

ko.javascript.info

 

시각화

자료를 웹 스프링 부트 애플리케이션

리눅스에 wap

그래프에 데이터베이스 

스크린 캡쳐 static 리소스로 넘겨서 보이게

데이터베이스 집어 넣어서 시각화

차트 js 차트 라이브러리 

 

https://github.com/GyuWonLee/SpringBoard

 

GitHub - GyuWonLee/SpringBoard

Contribute to GyuWonLee/SpringBoard development by creating an account on GitHub.

github.com

 

댓글