인텔리제이에서 Mysql 데이터소스를 연결하던중 위와 같은 오류가 발생하였다. 


JDBC에 타임존 정보를 추가로 설정한뒤 해당오류를 처리할 수 있다. 


1
jdbc:mysql://localhost:3306/test?serverTimezone=UTC
cs


현재 우리나리 기준으로 사용할경우는 ?serverTimezone=Asia/Seoul 사용해주면 된다.


출처 : https://offbyone.tistory.com/318

블로그 이미지

클라인STR

,

YAML 은 YAML Ain't Markup Language 약자이며 데이터 중심의 마크업 언어이다. 

YAML 을 설정하기위해서는 SnakeYAML 라이브러리가 필요하다. 스프링부트에 경우는 스타터에 해당라이브러리가 포함되어있다. 



1
2
3
4
5
server.port = 8443
server.ssl.key-store = keystore.p12
server.ssl.key-store-password = 
server.ssl.keyStoreType = PKCS12
server.ssl.keyAlias = tomcat

cs

[application.properties]



1
2
3
4
5
6
7
server:
  ssl:
    key-store: keystore.p12
    key-store-password: 
    keyStoreType: PKCS12
    keyAlias: tomcat
  port : 8443
cs

[application.yml] 



프로퍼티 파일을 yml로 변경할경우 다음과 같이 구성이된다. 계층 구조를 훨씬 쉽게 파악할 수 있다. 



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
server:
port : 80
---
spring:
  profiles:
    active: local # 기본 환경 선택
 
# local 환경
---
spring:
  profiles: local
  datasource:
    data: classpath:data-h2.sql # 시작할때 실행시킬 script
  jpa:
    show-sql: true
    hibernate:
      ddl-auto: create-drop
  h2:
    console:
      enabled: true
 
# 운영 환경
---
spring:
  profiles: set1
server:
  port: 8081
 
 
 

cs



로컬, 개발 , 운영 환경을 구분할때 ---  기준으로 설정값을 나눈다.  최상단 영역은 디폴트로 적용시킬 값을 위치하면된다. 




프로퍼티 값 읽어오기 


@Value 어노테이션과 @ConfigurationProperties 사용하여 읽어올 수 있다. 



1
2
3
4
5
6
7
property:
      test:
           name : property depth test
 
propertyTest : test
propertyTestList : a,b,c
 
cs

[application.yml]



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
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
import java.util.List;
import java.util.Map;
 
;import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
 
@RunWith(SpringRunner.class)
@SpringBootTest
public class PropertyTest {
 
    @Autowired
    FruitProeprty fruitProeprty;
 
 
    @Test
    public void test() {
        List<Map> fruitData = fruitProeprty.getList();
 
        assertThat(fruitData.get(0).get("name"), is("banana"));
        assertThat(fruitData.get(0).get("color"), is("yellow"));
 
        assertThat(fruitData.get(1).get("name"), is("apple"));
        assertThat(fruitData.get(1).get("color"), is("red"));
 
        assertThat(fruitData.get(2).get("name"), is("water melon"));
        assertThat(fruitData.get(2).get("color"), is("green"));
    }
 
}
 
cs






1
2
3
4
5
6
7
8
fruit:
  list:
    - name : banana
      color : yellow
    - name : apple
      color : red
    - name : water melon
      color : green

cs


[application.yml]


- 구분자를 사용하면 리스트로 인식한다. 



1
2
3
4
5
6
7
8
9
10
11
12
13
14
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
 
import java.util.List;
import java.util.Map;
 
@Data
@Component
@ConfigurationProperties("fruit")
public class FruitProeprty {
    private List<Map> list;
}
 
cs

[fruit 맵핑할 클래스를 생성한다.]



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
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
 
import java.util.List;
import java.util.Map;
 
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
 
@RunWith(SpringRunner.class)
@SpringBootTest
public class PropertyTest {
 
    @Autowired
    FruitProeprty fruitProeprty;
 
 
    @Test
    public void test() {
        List<Map> fruitData = fruitProeprty.getList();
 
        assertThat(fruitData.get(0).get("name"), is("banana"));
        assertThat(fruitData.get(0).get("color"), is("yellow"));
 
        assertThat(fruitData.get(1).get("name"), is("apple"));
        assertThat(fruitData.get(1).get("color"), is("red"));
 
        assertThat(fruitData.get(2).get("name"), is("water melon"));
        assertThat(fruitData.get(2).get("color"), is("green"));
    }
 
}
 
cs



참고링크 


http://wonwoo.ml/index.php/post/647

https://jeong-pro.tistory.com/159

https://kingbbode.tistory.com/10

블로그 이미지

클라인STR

,