[Spring Boot] log4j DB로그 확인
console을 통해서 db작업 확인을 하기 위해 추가하였다. 1. build.gradle // sql log implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16' 2. application.properties //application.properties spring.datasource.driverClassName=net.sf.log4jdbc.sql.jdbcapi.DriverSpy spring.datasource.url = jdbc:log4jdbc:mysql:~~~ 3. resources에 파일 두개 추가 //log4jdbc.log4j2.properties log4jdbc.spylogdelegator.name=net.sf.log4j..
2023.02.11
[SpringBoot] Spring Security
암호화 작업을 하기 위하여 스프링 시큐리티를 사용하였다. 1. build.gradle에 추가 //build.gradle //spring security implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' 2. util @EnableWebSecurity @AllArgsConstructor @Configuration public class SpringSecurity{ /** * 패스워드 암호화 * */ @Bean public PasswordEncoder getPasswordEncoder() { return n..
2023.02.11
[JAVA] 객체지향 프로그래밍
오버로딩 / 오버라이딩 오버로딩은 기존에 없는 새로운 메서드를 추가 오버라이딩은 조상으로부터 상속받은 메서드의 내용을 변경 super 자손 클래스에서 조상 클래스로부터 상속받은 멤버를 참조할때 사용 public class SuperTest { public static void main(String[] args) { Child c = new Child(); c.method(); } } class Parent{ int x = 10; } class Child extends Parent{ int x = 20; void method(){ System.out.println("x=" + x); // 20 System.out.println("this.x=" + this.x); // 20 System.out.printl..
2023.02.07
no image
[SpringBoot] MyBatis application.properties 설정
# mybatis settings mybatis.mapper-locations = mybatis/**/*.xml mybatis.config-location = classpath:mybatis-config.xml
2023.02.06
[SpringBoot] MySql application.properties 설정
# mysql database settings spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver spring.datasource.url = jdbc:mysql://localhost:3306/schema?serverTimezone=UTC&characterEncoding=UTF-8 spring.datasource.username = id spring.datasource.password = pw
2023.02.06
스프링부트 자동구성 애플리케이션
Meta Annotation Compose Annotation Annotation을 만들때 필요 @Retention @Target ElementType.TYPE : Class, Interface, Enum @Import
2023.02.06
스프링부트 테스트
public class HelloApiTest { @Test void helloApi(){ // http localhost:8080/hello?name=Spring TestRestTemplate rest = new TestRestTemplate(); ResponseEntity res = rest.getForEntity("http://localhost:8080/hello?name={name}", String.class, "Spring"); // status 200 Assertions.assertThat(res.getStatusCode()).isEqualTo(HttpStatus.OK); // header(content-type) text/plain Assertions.assertThat(res.getHead..
2023.02.06
스프링부트 스프링컨테이너
ApplicationContext가 스프링 컨테이너 이다. public static void main(String[] args) { GenericApplicationContext applicationContext = new GenericApplicationContext(); applicationContext.registerBean(HelloController.class); applicationContext.refresh(); ServletWebServerFactory serverFactory = new TomcatServletWebServerFactory(); WebServer webServer = serverFactory.getWebServer(servletContext -> { servletConte..
2023.02.05