2016-06-10 2 views
-2

run-app를 실행 한 후 grails 애플리케이션을 실행하려고합니다.java.lang.ClassNotFoundException : com.mysql.jdbc.Driv5r

| Loading Grails 2.1.1 

| Configuring classpath 

Resolving [test] dependencies... 

Resolving [runtime] dependencies... 

| Configuring classpath. 

| Environment set to development..... 

| Packaging Grails application..... 

| Compiling 54 source files 

| Compiling 54 source files.. 

| Compiling 43 source files 

warning: Implicitly compiled files were not subject to annotation processing. 
Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation. 
1 warning 
| Compiling 43 source files..... 
| Running Grails application 



Cannot load JDBC driver class 'com.mysql.jdbc.Driv5r' 
java.lang.ClassNotFoundException: com.mysql.jdbc.Driv5r 
at java.net.URLClassLoader$1.run(URLClassLoader.java:202) 
. 
. 
. 
. 


    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110) 
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:901) 
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) 
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:149) 
    at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 

는 왜 외부가 'com.mysql.jdbc.Driv5r'를 주문하지 'com.mysql.jdbc.Driver'

시도 Grails는 깨끗하고 새로 고침 종속성하지만 여전히 같은 오류 않습니다 이 드라이버 클래스를 추가하는 방법, 나는 GGTS에서 일하고있다.

+0

수동 방법은 msyql-connect-XXX.jar을 lib 폴더에 넣고 mysql 플러그인을 제거하는 것입니다. – Vahid

+0

이 오류를 유발하는 코드를 포함하십시오. –

답변

2

부주의 한 것 같습니다. com.mysql.jdbc.Driv5r 정말로.이 주된 이유는 datasource.groovy의 driverClassName 정의에서 맞춤법 오류입니다.

dataSource { 
    pooled = true 
    driverClassName = "com.mysql.jdbc.Driv5r" 
    dialect = "org.hibernate.dialect.MySQL5InnoDBDialect" 
    url = dataSourceProperties.getProperty("datasource.url") 
    username = dataSourceProperties.getProperty("datasource.username") 
    password = dataSourceProperties.getProperty("datasource.password") 
} 

com.mysql.jdbc.Driv5r에서 com.mysql.jdbc.DriverdriverClassName 정정.

이 외에도 BuildConfig.groovy에서 mysql에 대한 종속성을 추가했는지 확인하십시오.

0

코드를 확인하십시오.

Class.forName(driver);// here Check variable "driver" 
String driver="com.mysql.jdbc.Driver"; // here you might have typed "com.mysql.jdbc.Driv5r" 

또는

Class.forName("com.mysql.jdbc.Driver");//here you might have typed com.mysql.jdbc.Driv5r 

모든 다른 .. 그래서이 이유가 될 수 있습니다 잘 보이는

.

관련 문제