Framework/Spring Framework31 (23.01.11.)Spring ํ๋ ์์ํฌ : Spring Security -JDBC Authentication Spring Security -JDBC Authentication ์คํ๋ง ์ํ๋ฆฌํฐ์ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ์ฐ๋ํ์ฌ ์ธ๊ฐ, ์ธ์ฆ ๋ณด์์ ํ๋ ค๋ฉด 3๊ฐ์ง๊ฐ ์์ด์ผ ํ๋ค. -config ํด๋์ค์ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ๊ด๋ จ๋ ์ ๋ณด๊ฐ ์์ด์ผํ๋ค. (Datasource) -users์ authorities ํ ์ด๋ธ์ด ์์ด์ผ ํ๋ค. -๊ธฐ์กด์ ํ๋ In Memory Authentication ์ค์ ์ ๊ฑฐํด์ค์ผํ๋ค. users์ authorities ํ ์ด๋ธ ์์ฑ CREATE TABLE users ( username VARCHAR2(50) NOT NULL, password VARCHAR2(120) NOT NULL, enabled CHAR(1) NOT NULL, CONSTRAINT check_users_enabled CHECK(enabled .. Framework/Spring Framework 2023. 1. 11. (23.01.06)Spring ํ๋ ์์ํฌ : thymeleaf๋ฅผ ์ด์ฉํ ๋ณด์ ๋ก๊ทธ์ธ - ๋ก๊ทธ์ธ ์๋ฌ ๋ก๊ทธ์ธ ์๋ฌ ๋ฉ์์ง ๋์ฐ๊ธฐ pom.xml ์ค์ ์ (23.01.05)๊ฒ์๊ธ ์ฐธ๊ณ ! SimpleSecurityConfig.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 import org.springframework.beans.factory.annotation.Autowired; import org.s.. Framework/Spring Framework 2023. 1. 9. (23.01.05)Spring ํ๋ ์์ํฌ: ๋ก๊ทธ์ธ ๋ณด์ (SimpleSecurity) โโSpring ํ๋ ์์ํฌ๋ฅผ ์ฌ์ฉํ ๋ณด์๋ ๋ก๊ทธ์ธ ๊ธฐ๋ฅโโ ๋จผ์ ํผ ์ค์ ์ ํด์ค์ผํ๋ค. org.springframework.boot spring-boot-starter-security org.springframework.security spring-security-taglibs org.springframework.security spring-security-web org.springframework.security spring-security-config pom.xml ์ dependency์ ์ ์ฝ๋๋ฅผ ๋ฃ์ด์ค์ผ ํ๋ค. SimpleSecurityConfig.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 .. Framework/Spring Framework 2023. 1. 9. (23.01.04)Spring ํ๋ ์์ํฌ : Java Mail Sending (POP์ ํตํ ๋ฉ์ผ๋ณด๋ด๊ธฐ) โโ Java Mail Sending โโ Post Office Post Office Protocol(POP) POP -> POP3 (์์ฆ์ pop3 ๋ฒ์ ์ ์ด๋ค) POP3 implemented server : POP3 Server(mail server) Google POP3 Server is open All Gmail users allowed ์ค์ ์ฌํญ -Google 2 step Authorization -Pc, Smart Phone -App Secure codes -application.properties ๋ธ๋ผ์ฐ์ ์ฐ์๋จ ํ๋กํ ์ด๋ฏธ์ง > ๊ณ์ ๊ด๋ฆฌ > ๋ณด์ > Google์ ๋ก๊ทธ์ธ/2๋จ๊ณ ์ธ์ฆ > ์ฑ ๋น๋ฐ๋ฒํธ ์ค์ > ๋น๋ฐ๋ฒํธ ๋ณต์ฌ - ๋ณต์ฌ๋ ๋น๋ฐ๋ฒํธ๋ฅผ application.properties์ ์ ๋ ฅ .. Framework/Spring Framework 2023. 1. 4. (23.01.02)Spring ํ๋ ์์ํฌ: ์น์์ผ์ ์ด์ฉํ ์ฑํ ํ๋ก๊ทธ๋จ ๋ง๋ค๊ธฐ โโ ์น์์ผโโ - Thymeleaf, Websocket - HttpSession ์ ๋ฌ(Controller -> WebSocket) - Interceptor ๋ฐฉ์์ผ๋ก ServletContext ์ ๋ฌ - page, request, session, application - application : ์น์๋ฒ์ ํ๊ฐ๋ง ์กด์ฌ - application = ServletContext - Controller์์ ServletContext ์ HttpSession์ ์ฐธ์กฐ๋ฅผ ์ ์ฅ - ์ธํฐ์ ํฐ๋ฅผ ํตํด ServletContext ๋ฅผ WebSocket์ผ๋ก ์ ๋ฌ - WebSocket์์๋ WebSocketSession์ ํตํด์ ์ ๋ฌ๋ ์์ฑ ๊ฐ์ ์ถ์ถํ ์ ์๋ค - WebSocket์์๋ ๋จผ์ ServletContext๋ฅผ ์ถ์ถํ๊ณ .. Framework/Spring Framework 2023. 1. 2. (22.12.30)Spring ํ๋ ์์ํฌ:WebSocket์ ์ฌ์ฉํ ์ฑํ ํ๋ก๊ทธ๋จ ๋ง๋ค๊ธฐ WebSocket์ ์ฌ์ฉํ ์ฑํ ํ๋ก๊ทธ๋จ ๋ง๋ค๊ธฐ - Spring boot ๊ธฐ๋ฐ ๊ณ ์์ค - ์น์ฌ์ดํธ ์ ์์ ์ ์ฒด๋ฅผ ๋์์ผ๋ก ํ ์ฑํ - ํน์ ์ด์ฉ์ ๊ทธ๋ฃน/๊ฐ์ธ์ ๋์์ผ๋ก ํ ์ฑํ (์์ฉ ์์: ์ฑ๋ด , ์ฑํ ) -์น ์๋ฒ์์ ์๋ฒ ์์ผ์ ๋๊ณ ์น๋ธ๋ผ์ฐ์ ๊ฐ ์๋ฒ์์ผ์ ์ ์์์ฒญํ๋ ๊ฐ๋ (์น์๋ฒ-์น๋ธ๋ผ์ฐ์ ๊ฐ์ ํต์ ) -http ํ๋กํ ์ฝ์ ์ ์์์ฒญ ํ ์ ์๋๋ฉด ์๋ต์ ์ ์กํ๊ณ ์ ์ ํด์ ServerSocket : ๋คํธ์์๋ฒ, ๋ฌดํํ ํด๋ผ์ด์ธํธ๋ฅผ ๋๊ธฐํจ Socket : ์๋ฒ์ ์ ์ ์์ฒญ์ ํ ์ ์๋ ๊ธฐ๋ฅ์ด ์๋ค. ํต์ ๊ธฐ๋ฅ์ด ๋ค์ด์๋ค.(์๋ฐ ๊ฒฝ์ฐ) ์ ์์ค์ ์์ผ๊ณผ ์๋ฒ์์ผ ๋ง๊ณ ๊ณ ์์ค์ ์น์์ผ์ ์ฌ์ฉํ์ฌ ํ๋ก๊ทธ๋๋ฐํ๊ธฐ ์น ์์ผ ์ค์ ํ๊ธฐ - main Class 1 2 3 4 5 6 7 8 9 10 11 12 13 1.. Framework/Spring Framework 2022. 12. 30. (22.12.29)Spring ํ๋ ์์ํฌ: Thymeleaf, JPA, Spring ํ๋ ์์ํฌ์ dependencyํ์ฌ ํ์ฉ ๋ฐ CRUD โโ Thymeleaf์ JPA๋ฅผ ์ด์ฉํ CRUD โโ - JSP + EL - thymeleaf ( html + Spring EL ) Natural Templating: DB, Front End 1. Spring boot ํ๋ก์ ํธ ์๋ก ์์ฑ 2. application.properties, pom.xml ๋ณต์ฌ 3. application.properties, pom.xml์ thumeleaf ๊ด๋ จ ์ค์ ์ถ๊ฐ โโThymeleaf ์ค์ ํ๊ธฐโโ -application.properties # Thymeleaf spring.thymeleaf.cache=false spring.thymeleaf.prefix=classpath:/templates/ templates๋ผ๋ ํด๋ ๊ฒฝ๋ก์ spring.thymeleaf.suff.. Framework/Spring Framework 2022. 12. 29. (22.12.28)Spring ํ๋ ์์ํฌ: JPA ์ฐ๋ํ์ฌ ํ๋ก๊ทธ๋๋ฐ ํ๊ธฐ (๊ธฐ์ด) Spring ์์ JPA๋ก ํ๋ก๊ทธ๋๋ฐ ํ๊ธฐ Spring DataBase - JDBC - JdbcTemplate - MyBatis - JPA(Java Persistence API) JPA ์ค์ -application.properties -pom.xml : dependency ์ถ๊ฐ https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa VO CLASS JPA์์ VO๊ฐ ํ์ํ๋ค : Entity (DB์์ฑ์ ์งํฉ) Entity -> ํ ์ด๋ธ ์์ฑ (DB๋ชจ๋ธ๋งํ ๋ ์ค๊ณ๋จ๊ณ์์ ์ฐ๋ ์ฉ์ด.) - ์ฌ๋ฒ, ์ด๋ฆ, ๋ถ์, ๊ธ์ฌ, ์ ์ฌ ) : JpaRepository์์ ( ๊ธฐ๋ณธ์ ์ผ๋ก CRUD์ ๊ด๋ จ๋๊ฑด ๋ค ๊ตฌํ๋์ด์๋ค.. Framework/Spring Framework 2022. 12. 29. (22.12.27)Spring ํ๋ ์์ํฌ: Mybatis๋ก Spring๊ณผ Oracle ์ฐ๋ํ์ฌ ๊ฒ์ํ ์์ธ๋ณด๊ธฐ, ์ฒจ๋ถํ์ผ ๋ค์ด๋ก๋ํ๊ธฐ โโMybatis๋ก Spring๊ณผ Oracle ์ฐ๋ํ์ฌ ๊ฒ์ํ ์์ธ๋ณด๊ธฐ, ์ฒจ๋ถํ์ผ ๋ค์ด๋ก๋ํ๊ธฐโโ VOํด๋์ค๋ (22.12.26)๊ฒ์๋ฌผ๊ณผ ๋์ผํ๊ฒ ์ด์ฉํ๋ค. BoardMapper.xml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 INSERT INTO board(boardid, title, contents, author) VALUES(BOARD_SEQ.NEXTVAL, #{title,jdbcType=VARCHAR}, #{contents,jdbcType=VARCHAR}, #{author,jdbcType=VARCHAR}) IN.. Framework/Spring Framework 2022. 12. 27. (22.12.26)Spring ํ๋ ์์ํฌ: PageHelper๋ฅผ ์ด์ฉํ ๊ณ ์์ค pagination ๊ตฌํ, Mybatis๋ก Spring๊ณผ Oracle ์ฐ๋ํ์ฌ ๊ฒ์ํ ๋ฆฌ์คํธ ๋ณด๊ธฐ โโPageHelper๋ฅผ ์ด์ฉํ ๊ณ ์์ค pagination ๊ตฌํโโ -Oracle : ROWNUM,PageHelper -MySQL : LIMIT 2,3, PageHelper โโPageHelper ์ค์ ํด์ฃผ๊ธฐโโ -application.properties : oralce -pom.xml : dependency , PageHelper Spring boot starter BoardVO.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 import java.util.ArrayList; import java.util.List; import lombok.AllArgsConstructor; import lombok.Data; impor.. Framework/Spring Framework 2022. 12. 26. (22.12.23)Spring ํ๋ ์์ํฌ: Mybatis๋ก Spring๊ณผ Oracle ์ฐ๋ํ์ฌ ๊ฒ์ํ, ์ฒจ๋ถํ์ผ ์ฌ๋ฆฌ๊ธฐ BoardVO.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import java.util.ArrayList; import java.util.List; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.ToString; @Data @ToString @EqualsAndHashCode(exclude= {"title","author","regDate","contents","hit","attList"}) @AllArgsConstructor @NoArgsConst.. Framework/Spring Framework 2022. 12. 25. (22.12.22)Spring ํ๋ ์์ํฌ: Mybatis ๋ค์ด๋๋ฏนSQL, ์ฒจ๋ถํ์ผ ์ ๋ก๋ ๋ค์ด๋ก๋ ๊ธฐ๋ฅ ๋ง๋ค๊ธฐ โโ์ด๋ฆ ๋๋ ๋ถ์๋ฒํธ ํ๋๋ก ๊ฒ์ํ๋ ๊ธฐ๋ฅ ๋ง๋ค๊ธฐ(๋ค์ด๋๋ฏน sql ) โโ MybatisEmpController.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; im.. Framework/Spring Framework 2022. 12. 22. ์ด์ 1 2 3 ๋ค์