티스토리 뷰

1. 자바

자바/스프링/2020-08-31/ SpringBoot Security 설정

패스트코드블로그 2020. 8. 31. 20:38

 

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
server:
  port: 5555
 
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/projdb?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf8
    username: bitai
    password: 456123
    driver-class-name: com.mysql.cj.jdbc.Driver
 
  jpa:
    open-in-view: false
    database: mysql
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    generate-ddl: true
    show-sql: true
    hibernate:
      ddl-auto: update
 
  jackson:
    serialization:
      fail-on-empty-beans: false
 
logging:
  level:
    org:
      hibernate:
        SQL: DEBUG
 
    app:
      sample:
        message:
          AuditingFilter: DEBUG
          SecurityChecker: DEBUG
          MessageService: DEBUG
 
cs

 

DBConfig.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
package com.hanoi.ok.config;
 
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
 
import javax.sql.DataSource;
 
// 게시판 만들 때 DB 연동시키려고 생성해줌.
// Configuration은 설정파일임을 명시하는 부분이다.
// 몇몇 특정 지정된 키워드들을 제외한 사용자 커스텀 클래스의 경우엔
// 설정 파일임을 명시해줄 필요가 있다.
@Configuration
public class DBConfig {
    // Spring 프레임워크에서 관리하는 객체를 Bean이라 한다.
    @Bean
    public DataSource dataSource() {
        // -> JPA를 사용하기 위한 목적으로 설정하는 것들
        // MYSQL의 사용자 비번 구동 드라이버 위치등을 지정하면 된다. <-
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        // application.yaml에 있는 내용을 적어주면 됨.
        dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
        dataSource.setUrl("jdbc:mysql://localhost:3306/projdb?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf8");
        dataSource.setUsername("bitai");
        dataSource.setPassword("456123");
        return dataSource;
    }
}
 
cs
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
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
글 보관함