空指針異常
<?xml?version="1.0"?encoding="UTF-8"?>
<beans?xmlns="http://www.springframework.org/schema/beans"
???????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
???????xmlns:aop="http://www.springframework.org/schema/aop"
???????xmlns:tx="http://www.springframework.org/schema/tx"
???????xmlns:context="http://www.springframework.org/schema/context"
???????xsi:schemaLocation="http://www.springframework.org/schema/beans
????????http://www.springframework.org/schema/beans/spring-beans.xsd
????????http://www.springframework.org/schema/aop
????????http://www.springframework.org/schema/aop/spring-util.xsd
????????http://www.springframework.org/schema/tx
????????http://www.springframework.org/schema/context
????????http://www.springframework.org/schema/context/spring-context.xsd">
??????<!--?引入外部屬性文件?-->
????<context:property-placeholder?location="classpath:jdbc.properties"/>
????<!--?配置c3p0的連接池?-->
????<bean?id="dataSource"?class="com.mchange.v2.c3p0.ComboPooledDataSource">
????????<property?name="driverClass"?value="${jdbc.driver}"/>
????????<property?name="jdbcUrl"?value="${jdbc.url}"/>
????????<property?name="user"?value="${jdbc.user}"/>
????????<property?name="password"?value="${jdbc.password}"/>
????</bean>
????<!--?配置業(yè)務(wù)類?-->
????<bean?id="accountService"?class="com.demo.AccountServiceInpl">
????????<property?name="accountDao"?ref="accountDao"/>
????????<context:component-scan?base-package="com.demo"/>
????</bean>
????<!--?配置dao類?-->
????<bean?id="accountDao"?class="com.demo.AccountDaoImpl">
????????<property?name="dataSource"?ref="dataSource"></property>
????</bean>配置文件如上圖? 不知道問題在哪
2018-08-05
你把這行配置放到<bean>外邊試試,不行我也看不出有什么毛病了
2018-08-07
c3p0連接池用戶名那行確定是${jdbc.user}?,應(yīng)該不是的吧
2018-08-05
咦?回復(fù)怎么這么奇怪?com.demo.AccountServiceInpl改成com.demo.AccountServiceImpl
2018-08-05
application配置文件 id為accountService的bean類名稱寫錯了吧??
2018-08-05
2018-08-05
java.lang.NullPointerException
at com.demo.Test1.Test1(Test1.java:22)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
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.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:83)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
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.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
2018-08-05
報錯信息發(fā)上來