예외에 대한 catch 블럭에서 예외에 대한 처리가 필수적으로 있어야한다.
예외처리가 되지 않는다면 프로그램이 비정상적으로 동작하거나, 메모리가 소진될 수도 있다.
예외처리를 하지않고 의미없는 throws Exception은 문제에 대한 정확한 파악이 힘들다.
중첩예외로 만든다.
catch(SQLException e) {
if(e.getErrorCode() == MySqlErrorNumbers.ER_DUP_ENTRY){
throw DuplicatedUserIdException();
} else {
throw e;
}
}
예외를 처리하기 쉽고 단순하게 만들기 위해 포장한다.
checked exception을 unchecked exception으로 변경할 경우 사용
catch(SQLException se) {
throw new EJBException(se);
}
https://www.acmicpc.net/problem/2720
[나의 풀이]
import sys
n = int(sys.stdin.readline())
money_unit = [0.25, 0.1, 0.05, 0.01]
answer = ''
for i in range(n):
money = int(sys.stdin.readline()) / 100
for unit in money_unit:
for j in range(1, 101):
if (unit * j) == money:
answer += str(j) + " "
money = round(money - (unit * (j)), 2)
break
elif (unit * j) >= money:
answer += str(j - 1) + " "
money = round(money - (unit * (j - 1)), 2)
break
print(answer)
answer = ''
탐욕법으로 푼다고 생각해서 전체값에서 빼서 남은값을 반복적으로 계산한다고 생각했는데 배열의 값에서 나머지값 연산으로 쉽게 계산이 가능 한 문제였다…
[모범답안]
import sys
n = int(sys.stdin.readline())
for i in range(n):
C = int(input())
ans = [0, 0, 0, 0]
changes = [25, 10, 5, 1]
for c in range(len(changes)):
ans[c] += C // changes[c]
C %= changes[c]
print(*ans)
compileOnly "org.springframework.boot:spring-boot-starter-security"
implementation "org.springframework.boot:spring-boot-starter-security"
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
public class HeeverseTicketApplication {
public static void main(String[] args) {
SpringApplication.run(HeeverseTicketApplication.class, args);
}
}

SecurityAutoConfiguration : 스프링 부트 시큐리티 자동설정 담당하며, 자동설정을 끄고자할때는 exclue로 설정할 수 있다.
개발자가 설정한 커스텀이 있다면 자동설정보다 우선으로 설정되는데, 위의 경우는 HttpSecurity가 스프링 자동설정으로 들어오는 객체여서 exclude 시 autowired가 불가하다고 뜨는것 같다.
일반적으로 둘 중 하나가 다른 하나를 어떤 용도로 사용함에 있어 둘의 관계를 뜻한다.
의존성에 있는 두 관계는 수행 순서 지정이 필요하다.
[참고]
https://docs.gradle.org/current/userguide/declaring_dependencies.html
https://www.baeldung.com/gradle-implementation-vs-compile
https://docs.gradle.org/current/userguide/java_plugin.html#tab:configurations
감사합니다. 이런 정보를 나눠주셔서 좋아요.