Resources中获取的dricerClass没用

来源:2-3 JDBCUtil开发

zmy199202070012

2017-05-16 11:09

从resources中获取user url password 和dricerClass时候报错,但是在JDBCUtil中硬编码的时候能够连接上mysql 

java.lang.ClassNotFoundException: "com/mysql/jdbc/Driver";


at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:264)

at com.lancet.util.JDBCUtil.getConnection(JDBCUtil.java:39)

at com.lancet.util.JDBCUtilTest.testGetConnetion(JDBCUtilTest.java:15)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)

at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)

at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)

at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)


写回答 关注

5回答

  • 慕容5618489
    2019-01-16 14:53:18

    首先你的配置文件没有引用进来,其次你的配置文件多了引号和分号

  • 未卜先知
    2017-06-06 15:24:22

    多了引号和分号,开始我也这样,去了就好了

  • zmy199202070012
    2017-05-23 09:33:18

    密码是没有设置所以不需要写

  • zmy199202070012
    2017-05-17 14:57:43

    感觉没错http://img.mukewang.com/591bf4640001627404950143.jpg

    慕容5618...

    分号去掉

    2019-01-16 14:51:40

    共 4 条回复 >

  • 一个稻草人
    2017-05-16 21:19:45

    是不是你的db.properties配置文件中写错了?

轻松愉快之玩转SpringData

利用Spring Data提高开发效率,提升程序员的幸福指数

34087 学习 · 119 问题

查看课程

相似问题