Spring/Batch

[Spring Boot Batch] 오류: "Failed to configure a DataSource: ‘url’ attribute is not...". 오류해결

HANDA개발 2022. 9. 13. 16:13
spring:
  config:
    activate:
      on-profile: mysql
  datasource:
    hikari:
      driver-class-name: com.mysql.jdbc.Driver
      jdbc-url: jdbc:mysql://localhost:3306/springBatch?useUnicode=true&character_set_server=utf8;
      username: kimhee
      password: sn8657sn
  batch:
    jdbc:
      initialize-schema: always

내 경우에 application.yml에 db관련 설정 후, 실행 시 url 설정이 잘못되었다는 오류가 자꾸났다.

퍼온 이미지이지만 똑같은 오류였음.

application.yml 파일에 아래와 같이 jdbc driver 관련 설정 추가하는게 해결방법이라고 나오는데

이미 설정을 했음에도 같은 오류가 났다.

 

그래서 className과  pom.xml에 db 관련 의존성들을 다시 체크해주었다.

className 체크

 

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.27</version>
            <scope>runtime</scope>
        </dependency>

mysql 버전은 utf8오류가 나지 않도록 8.0.27 버전을, 그리고 h2의존성도 다시한번 넣어 maven을 리로딩해주었다.

해결된 후 잘 돌아감. 테이블들도 잘 생성됨.

 

 

 

https://stackoverflow.com/questions/46140583/caused-by-java-sql-sqlexception-unsupported-character-encoding-utf8mb4

 

Caused by: java.sql.SQLException: Unsupported character encoding 'utf8mb4'

I am writing an app that is going to heavily use utf-8 encoding. For the server I'm using java servlets, and for the UI I'm using Java Servlets with jsp and javascript. So, after ignoring the gibbe...

stackoverflow.com

https://www.yawintutor.com/failed-to-configure-a-datasource-failed-to-determine-a-suitable-driver-class/

 

Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured. Reason: F

Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured exception occurs when the datasource url is not configured in the spring boot application.properties. The spring boot reason is Reason: Fa

www.yawintutor.com