MapleStory Finger Point

๐ŸŸค JAVA 102

[JAVA] ์ปดํŒŒ์ผ / ๋Ÿฐํƒ€์ž„ / JVM ๊ตฌ์กฐ

์ปดํŒŒ์ผ (Compile)์†Œ์Šค์ฝ”๋“œ๊ฐ€ ๊ธฐ๊ณ„์–ด๋กœ ๋ณ€ํ™˜๋˜๋Š” ๊ณผ์ • (์ปดํŒŒ์ผ๋Ÿฌ javac๊ฐ€ ์ž๋ฐ” ๋ฐ”์ดํŠธ ์ฝ”๋“œ๋กœ ๋ณ€ํ™˜)`.java` -> `.class`  ๋Ÿฐํƒ€์ž„ (Runtime)ํ”„๋กœ๊ทธ๋žจ์ด ์‹ค์ œ๋กœ ์‹คํ–‰๋˜๋Š” ์‹œ๊ฐ„ ์ปดํŒŒ์ผ๋œ ๋ฐ”์ดํŠธ ์ฝ”๋“œ๊ฐ€ JVM ์— ์˜ํ•ด ์‹คํ–‰๋˜๋Š” ์‹œ์   ์ปดํŒŒ์ผ๊ณผ ๋Ÿฐํƒ€์ž„์˜ ์ฐจ์ด์ ์‹œ์ ํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ์ „์—, ์ฝ”๋“œ ์ž‘์„ฑ ํ›„ ์ปดํŒŒ์ผ ์‹œ์ ์— ๋ฐœ์ƒํ”„๋กœ๊ทธ๋žจ ์‹คํ–‰ ์ค‘์— ๋ฐœ์ƒ๋ชฉ์ ์†Œ์Šค ์ฝ”๋“œ์˜ ์˜ค๋ฅ˜๋ฅผ ๋ฏธ๋ฆฌ ํ™•์ธํ•˜๊ณ , ๋ฐ”์ดํŠธ์ฝ”๋“œ๋กœ ๋ณ€ํ™˜์‹ค์ œ๋กœ ํ”„๋กœ๊ทธ๋žจ์„ ์‹คํ–‰ํ•˜๊ณ  ๋™์  ์˜ค๋ฅ˜๋ฅผ ์ฒ˜๋ฆฌ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ๋ฌธ๋ฒ• ์˜ค๋ฅ˜, ํƒ€์ž… ์˜ค๋ฅ˜, ์ฒดํฌ ์˜ˆ์™ธ ๋ฏธ์ฒ˜๋ฆฌ ๋“ฑ (์ปดํŒŒ์ผ ์‹œ ๋ฐœ์ƒ)๋Ÿฐํƒ€์ž„ ์˜ˆ์™ธ(๋ฐฐ์—ด ์ธ๋ฑ์Šค ์ดˆ๊ณผ, null ์ฐธ์กฐ ๋“ฑ) (์‹คํ–‰ ์‹œ ๋ฐœ์ƒ)์˜ˆ์‹œ ์˜ค๋ฅ˜๊ตฌ๋ฌธ ์˜ค๋ฅ˜, ํƒ€์ž… ์˜ค๋ฅ˜, ์ฒดํฌ ์˜ˆ์™ธ ๋ฏธ์ฒ˜๋ฆฌNullPointerException, ArrayIndexOutO..

[JAVA] Exception ์˜ˆ์™ธ ์ฒ˜๋ฆฌ

๋ชฉ์ฐจ    ์˜ˆ์™ธ ๋ž€?ํ”„๋กœ๊ทธ๋žจ์˜ ์ •์ƒ์ ์ธ ํ๋ฆ„์„ ๋ฐฉํ•ดํ•˜๋Š” ๋ฌธ์ œ ์ƒํ™ฉ (ํ”„๋กœ๊ทธ๋žจ ์ฝ”๋“œ์—์„œ ์ฒ˜๋ฆฌ ๊ฐ€๋Šฅ , ๋…ผ๋ฆฌ์  ์˜ค๋ฅ˜) ์—๋Ÿฌ๋Š” ๊ทธ๋ณด๋‹ค ๋” ์‹ฌ๊ฐํ•œ ๋ฌธ์ œ (ํ”„๋กœ๊ทธ๋žจ ์ค‘๋‹จ ๋“ฑ์˜ ์‹ฌ๊ฐํ•œ ๋ฌธ์ œ , JVM / ๋ฉ”๋ชจ๋ฆฌ ๋ถ€์กฑ)  ์˜ˆ์™ธ ์ข…๋ฅ˜์ฒดํฌ ์˜ˆ์™ธ : ์ปดํŒŒ์ผ ์‹œ์ ์—์„œ ์˜ˆ์™ธ ๊ฐ•์ œ ์ฒ˜๋ฆฌ์–ธ์ฒดํฌ ์˜ˆ์™ธ : ๋Ÿฐํƒ€์ž„ ์‹œ์ ์—์„œ ๋ฐœ์ƒ (์ปดํŒŒ์ผ ์‹œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ ๊ฐ•์ œ ๋˜์ง€ ์•Š์Œ)    ์˜ˆ์™ธ ๊ณ„์ธต ๊ตฌ์กฐ  `Throwable` ํด๋ž˜์Šค๋Š” ๋ชจ๋“  ์˜ˆ์™ธ์™€ ์˜ค๋ฅ˜์˜ ๋ถ€๋ชจ ํด๋ž˜์Šค  `getMessage()`: ์˜ˆ์™ธ ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.`printStackTrace()`: ์˜ˆ์™ธ ๋ฐœ์ƒ ์‹œ ์Šคํƒ ํŠธ๋ ˆ์ด์Šค๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.`getCause()`: ์˜ˆ์™ธ์˜ ์›์ธ(๋‹ค๋ฅธ ์˜ˆ์™ธ)์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.   ๊ธฐ๋ณธ ์˜ˆ์™ธ์ฒ˜๋ฆฌ  (try-catch) `try`  ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ๋Š” ์ฝ”๋“œ`cat..

[JAVA 8+] java.time ํŒจํ‚ค์ง€

https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html java.time (Java Platform SE 8 )Class Summary  Class Description Clock A clock providing access to the current instant, date and time using a time-zone. Duration A time-based amount of time, such as '34.5 seconds'. Instant An instantaneous point on the time-line. LocalDate A date withoudocs.oracle.com  java.time ํŒจํ‚ค์ง€ ๊ธฐ์กด `java..

[JAVA 8+] Optional ๊ฐ์ฒด

https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html Optional (Java Platform SE 8 )A container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value. Additional methods that depend on the presence or absence of a contained value are provided, such as orEldocs.oracle.com   Optional ๊ฐ์ฒด๋ž€? Java 8 ์—์„œ ๋„์ž…๋œ..

[JAVA 8+] Stream API

๋ชฉ์ฐจ    Stream API ๋ž€ ?Java 8 ์—์„œ ๋„์ž…๋œ ๊ธฐ๋Šฅ์œผ๋กœ, ์ปฌ๋ ‰์…˜ / ๋ฐฐ์—ด์˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์Šคํƒ€์ผ๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ๋•๋Š”๋‹ค.๋ฐ์ดํ„ฐ ์›๋ณธ์„ ๋ณ€๊ฒฝํ•˜์ง€ ์•Š๊ณ , ์›๋ณธ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜๋ฆฌํ•œ ๊ฒฐ๊ณผ๋ฅผ ์ƒˆ๋กœ์šด ์ŠคํŠธ๋ฆผ์œผ๋กœ ๋ณ€ํ™˜ํ•œ๋‹ค. https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html w.getColor() == RED) .mapToInt(w -> w.getWeight()) " data-og-host="docs.oracle.com" data-og-source-url="https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html" data-og-url="https..

[JAVA 8+] ๋žŒ๋‹ค์‹ ๊ฐœ๋… / ์˜ˆ์ œ

๋žŒ๋‹ค์‹์ต๋ช… ํ•จ์ˆ˜(anonymous function) ํ˜•ํƒœ๋ฅผ ๊ฐ€์ง„ ํ‘œํ˜„์‹  ๋žŒ๋‹ค์‹ ๊ธฐ๋ณธ ๋ฌธ๋ฒ•(๋งค๊ฐœ๋ณ€์ˆ˜) -> { ์‹คํ–‰์ฝ”๋“œ } ๋งค๊ฐœ๋ณ€์ˆ˜ : ๋ฉ”์„œ๋“œ์— ์ „๋‹ฌํ•  ์ž…๋ ฅ๊ฐ’ ์ •์˜(->) : ๋žŒ๋‹ค ์—ฐ์‚ฐ์ž (arrow operator){ ์‹คํ–‰์ฝ”๋“œ } : ๋ฉ”์„œ๋“œ์˜ ์‹คํ–‰ ๋‚ด์šฉ์„ ์ž‘์„ฑ  int add(int x, int y) { return x + y; } // ๋ฉ”์„œ๋“œ ๋ฐ˜ํ™˜ ํƒ€์ž… , ๋ฉ”์„œ๋“œ๋ช… ์ƒ๋žต (int x , int y ) -> { return x + y; } // ๋งค๊ฐœ๋ณ€์ˆ˜ ํƒ€์ž… ์ƒ๋žต (x,y) -> { return x + y ; } // ๋ฆฌํ„ด๋ฌธ๋งŒ ์žˆ๋Š”..

[Spring Security] ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” ๊ตฌํ˜„

( ์ œ๊ฐ€ ์ž‘์—…ํ–ˆ๋˜  ํ”„๋กœ์ ํŠธ ์ฝ”๋“œ ๊ธฐ๋ฐ˜์œผ๋กœ ์„ค๋ช…ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.)   ์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™”์— ๊ด€ํ•œ ์ด๋ก ์€ ์ด์ชฝ ๊ฒŒ์‹œ๋ฌผ ์ฐธ๊ณ  ! https://hyejux.tistory.com/801 [Spring Security] BCrypt ํ•ด์‹œ ํ•จ์ˆ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜Spring Security ์—์„œ๋Š” BCryptPasswordEncoder ๋ผ๋Š” ํด๋ž˜์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š”๋ฐ์ด ํด๋ž˜์Šค๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์•”ํ˜ธํ™”ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. ์ด๋•Œ ์•”ํ˜ธํ™” ๋ฐฉ์‹์„ BCrypt ํ•ด์‹œ ํ•จ์ˆ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉํ•˜๋Š”๋ฐBCrypt ํ•ด์‹œ ํ•จ์ˆ˜ ์•Œ๊ณ hyejux.tistory.com https://hyejux.tistory.com/802 [Spring Security] BCryptPasswordEncoder ํด๋ž˜์Šค[ ์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” ] BCryptPass..

[Spring Security] ๊ถŒํ•œ ์ฒ˜๋ฆฌ

๋ชฉ์ฐจ   ( ์ œ๊ฐ€ ์ž‘์—…ํ–ˆ๋˜  ํ”„๋กœ์ ํŠธ ์ฝ”๋“œ ๊ธฐ๋ฐ˜์œผ๋กœ ์„ค๋ช…ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.) 1. ๊ถŒํ•œ ์ž‘์—… (EmployeeDetails.java)  // ๊ถŒํ•œ ๊ด€๋ จ ์ž‘์—…์„ ์œ„ํ•œ ๋ฉ”์„œ๋“œ @Override public Collection getAuthorities() { Collection authorities = new ArrayList(); try { // Employee์˜ authorityGrade๋ฅผ UserRole Enum์œผ๋กœ ๋ณ€ํ™˜ UserRole role = UserRole.valueOf(employee.getAuthorityGrade()); // ๊ถŒํ•œ์— ROLE_ ์ ‘๋‘์‚ฌ ๋ถ™์—ฌ ์ถ”๊ฐ€ authorities.add(new SimpleGrantedAuthority("R..

[Spring Security] ๋กœ๊ทธ์ธ ๊ตฌํ˜„

๋ชฉ์ฐจ   ( ์ œ๊ฐ€ ์ž‘์—…ํ–ˆ๋˜  ํ”„๋กœ์ ํŠธ ์ฝ”๋“œ ๊ธฐ๋ฐ˜์œผ๋กœ ์„ค๋ช…ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.)   1. build gradle ์— ์˜์กด์„ฑ ์ถ”๊ฐ€ //์‹œํ๋ฆฌํ‹ฐ ๋ฒ„์ „์€ ์Šคํ”„๋ง๋ฒ„์ „์— ๋”ฐ๋ผ ์‚ฌ์šฉ๋ฐฉ๋ฒ•์ด ์™„์ „ํžˆ ๋‹ค๋ฆ…๋‹ˆ๋‹ค. //์‹œํ๋ฆฌํ‹ฐ 5๋ฒ„์ „ => ์Šคํ”„๋ง ๋ถ€ํŠธ 2๋ฒ„์ „ (์ˆ˜์—…) //์‹œํ๋ฆฌํ‹ฐ 6๋ฒ„์ „ => ์Šคํ”„๋ง ๋ถ€ํŠธ 3๋ฒ„์ „ (๋ฌธ๋ฒ•์ด ์™„์ „ ๋ณ€๊ฒฝ๋˜๋‹ˆ ์ฃผ์˜) implementation 'org.springframework.boot:spring-boot-starter-security' //์‹œํ๋ฆฌํ‹ฐ ํƒ€์ž„๋ฆฌํ”„์—์„œ ์‚ฌ์šฉ implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' //์‹œํ๋ฆฌํ‹ฐ ํ…Œ์ŠคํŠธ testImplementation 'org.springframework.security:sp..

[Spring Security] Authentication(์ธ์ฆ)

์‹œํ๋ฆฌํ‹ฐ ๊ธฐ๋ณธ ํ‚ค์›Œ๋“œ Filter ๊ธฐ๋ฐ˜ ๋™์ž‘ (ํ•„ํ„ฐ์ฒด์ธ)๋ชจ๋“  ์š”์ฒญ์€ ํ•„ํ„ฐ๋ฅผ ๊ฑฐ์น˜๊ฒŒ ๋œ๋‹ค. ์ ‘๊ทผ ์ฃผ์ฒด(Principal) : ๋ณดํ˜ธ๋œ ๋Œ€์ƒ์— ์ ‘๊ทผํ•˜๋Š” ์ฃผ์ฒด(์œ ์ €) ์ธ์ฆ(Authentication) : ์ฆ๋ช…, ์œ ์ €๊ฐ€ ๋ˆ„๊ตฌ์ธ์ง€ ํ™•์ธํ•˜๋Š” ๊ฒƒ, ํ†ต์ƒ ํšŒ์›๊ฐ€์ž…ํ•˜๊ณ  ๋กœ๊ทธ์ธํ•˜๋Š” ๊ฒƒ์„ ๋งํ•œ๋‹ค. ๊ถŒํ•œ(Role) : ๋กœ๊ทธ์ธ ๋œ ์‚ฌ๋žŒ + role (๊ถŒํ•œ) ์ด ์žˆ๋Š” ์‚ฌ๋žŒ์ธ๊ฐ€(Authorization) : ํ—ˆ๋ฝ, ์œ ์ €์— ๋Œ€ํ•œ ๊ถŒํ•œ์„ ํ™•์ธ, ํ—ˆ๋ฝํ•˜๋Š” ๊ฒƒ   ๋กœ๊ทธ์ธ ์ธ์ฆ ์ฒ˜๋ฆฌ ๊ณผ์ •  1.  User ๊ฐ€ ๋กœ๊ทธ์ธ ์ •๋ณด + ์ธ์ฆ ์š”์ฒญ์„ ํ•œ๋‹ค (Http Request) 2. ๋ชจ๋“  ์š”์ฒญ์€ `AuthenticationFilter` ๋ฅผ ๊ฑฐ์น˜๊ฒŒ ๋œ๋‹ค. (๋ชจ๋“  ์š”์ฒญ ๊ฐ€๋กœ์ฑ„๊ธฐ)3.  `UsernamePasswordAuthenticationToken`(..