일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 타이젠
- 손민한
- NC 다이노스
- 리뷰
- 김경문
- 데이터베이스
- 야구
- Linux
- 해외직구
- 문파문파
- arm
- 블로그
- ubuntu 12.04
- 우분투
- 국정원
- 단통법
- 애플
- 조세피난처
- 태그를 입력해 주세요.
- 인공지능
- python
- 안드로이드
- mysql
- 뉴스타파
- 문파문파 공략
- 디자인 패턴
- Tizen
- 프로야구
- ubuntu
- NC다이노스
- Today
- Total
꿈꾸는 사람.
[Windows][MySQL 8.0.13][DataSource]Loading class `com.mysql.jdbc.Driver'. This is deprecated. 본문
[Windows][MySQL 8.0.13][DataSource]Loading class `com.mysql.jdbc.Driver'. This is deprecated.
현무랑 니니 2018. 12. 30. 19:19스프링과 MyBatis를 함께 사용하기 위해 root-context.xml에 DataSource를 추가하여 JUnit로 테스트하면
com.mysql.jdbc.Driver 클래스를 로딩할 때 오류가 발생한다.
이 오류는 com.mysql.jdbc.Driver가 오래되어 더이상 사용되지 않기 때문에 발생하며, 새로운 클래스인 com.mysql.cj.jdbc.Driver를 사용하면 해결된다고 한다.
1. com.mysql.jdbc.Driver 관련 오류
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. |
2. 원인
nini01/src/main/webapp/WEB-INF/spring/root-context.xml 파일에서 driverClassName 정의가 이전 클래스를 사용하기 때문이다.
<bean id = "dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://127.0.0.1:3306/nini_schema"></property> <property name="username" value="nini"></property> <property name="password" value="test"></property> </bean> |
3. 수정
driverClassName을 com.mysql.cj.jdbc.Driver로 바꿔준다.
<bean id = "dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property> <property name="url" value="jdbc:mysql://127.0.0.1:3306/nini_schema"></property> <property name="username" value="nini"></property> <property name="password" value="test"></property> </bean> |
4. 해결
Run As >> JUnit Test 하여 테스트를 실행하면 Connection 객체, com.mysql.cj.jdbc.ConnectionImpl@4bc222e가 정상적으로 생성된 것을 확인할 수 있다.
INFO : org.springframework.test.context.TestContextManager - @TestExecutionListeners is not present for class [class com.nini.niniapp1.DataSourceTest]: using defaults. INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [C:\workspace-sts-3.7.3\nini01\src\main\webapp\WEB-INF\spring\appServlet\servlet-context.xml] INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from file [C:\workspace-sts-3.7.3\nini01\src\main\webapp\WEB-INF\spring\root-context.xml] INFO : org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext@6aaa5eb0: startup date [Sun Dec 30 19:07:49 KST 2018]; root of context hierarchy INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3bd94634: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,dataSource,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy INFO : org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.nini.niniapp1.HomeController.home(java.util.Locale,org.springframework.ui.Model) INFO : org.springframework.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0' INFO : org.springframework.jdbc.datasource.DriverManagerDataSource - Loaded JDBC driver: com.mysql.cj.jdbc.Driver com.mysql.cj.jdbc.ConnectionImpl@4bc222e INFO : org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext@6aaa5eb0: startup date [Sun Dec 30 19:07:49 KST 2018]; root of context hierarchy INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3bd94634: defining beans [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.web.servlet.view.InternalResourceViewResolver#0,homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,dataSource,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy |
'IT > Database' 카테고리의 다른 글
[Database][Oracle Database 11g] 삭제 방법 (4) | 2019.02.08 |
---|---|
[Database][Oracle Database 11g] 설치 과정 (0) | 2019.01.16 |
[Windows][MySQL 8.0.13][JDBC Driver] time zone 오류 해결 (0) | 2018.12.18 |
[MySQL][Error 13 해결] 파일 읽기/쓰기 실패 (Can't create/write to file) (2) | 2017.02.10 |
[초간단 SQL 학습][MySQL] 파일로부터 데이터를 읽어오기. (0) | 2017.02.08 |