急求老师解决:java.lang.NoClassDefFoundError

急求老师解决:java.lang.NoClassDefFoundError

无法插入成功数据。jar已正确导入

java.lang.NoClassDefFoundError: Could not initialize class com.imooc.jdbc.utils.JDBCUtils

http://img1.sycdn.imooc.com//climg/5c9875c2000178bb03170307.jpg

代码部分和老师写的一模一样,编译时没有错误,运行就出错。IDE环境:eclipse

http://img1.sycdn.imooc.com//climg/5c98763e0001b7e709310565.jpg

http://img1.sycdn.imooc.com//climg/5c98764f0001e06905100097.jpg

http://img1.sycdn.imooc.com//climg/5c98765f0001aca306710561.jpg

运行错误信息:

java.lang.NoClassDefFoundError: Could not initialize class com.imooc.jdbc.utils.JDBCUtils

at com.imooc.jdbc.demo1.JDBCDemo3.demo1(JDBCDemo3.java:33)

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:50)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:39)

at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)

at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)

at java.util.Iterator.forEachRemaining(Iterator.java:116)

at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)

at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)

at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)

at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)

at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)

at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)

at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)

at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:79)

at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:70)

at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)

at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)

at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)

at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)

at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)

at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:89)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)


正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学你好,jdbc.properties文件应该放在src目录下,同学调整一下再试试。如:

http://img1.sycdn.imooc.com//climg/5c9881ca0001703302500128.jpg

如果我的回答解决了你的疑惑,请采纳。祝:学习愉快~

  • 拓扑95 提问者 #1
    谢谢老师,已经解决!
    2019-03-25 16:56:40
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
Java数据库开发与实战应用2018版
  • 参与学习           人
  • 提交作业       277    份
  • 解答问题       4297    个

Java数据库开发的必备技能,从流行的MySQL数据库开始,到Java原生的数据库管理接口JDBC的使用,再到常用的数据持久化框架MyBatis,让你向Java工程师的目标又迈进了一步!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师