首页 新闻 会员 周边 捐助

javaee报错,找不到文件

0
悬赏园豆:100 [已关闭问题] 关闭于 2017-12-22 09:01

这是我的spring-mybatis:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans default-lazy-init="true"
 3     xmlns="http://www.springframework.org/schema/beans" 
 4     xmlns:p="http://www.springframework.org/schema/p"
 5     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 6     xmlns:context="http://www.springframework.org/schema/context"
 7     xmlns:tx="http://www.springframework.org/schema/tx"
 8     xmlns:mvc="http://www.springframework.org/schema/mvc"
 9     xsi:schemaLocation="  
10        http://www.springframework.org/schema/beans   
11        http://www.springframework.org/schema/beans/spring-beans-4.3.xsd  
12        http://www.springframework.org/schema/mvc   
13        http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd   
14        http://www.springframework.org/schema/tx   
15        http://www.springframework.org/schema/tx/spring-tx-4.3.xsd   
16        http://www.springframework.org/schema/context  
17        http://www.springframework.org/schema/context/spring-context-4.3.xsd" >  
18 
19      <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
20        <property name="dataSource" ref="dataSource"></property>
21        <property name="configLocation" value="classpath:mybatis-config.xml"></property>
22        <!-- 自动扫描mapping.xml文件 -->
23        <property name="mapperLocations" >
24             <list>
25             <value>classpath:/mapper/*.xml</value>
26             </list>
27         </property>
28      </bean>
29  <!-- Mapper接口所在包,Spring会自动查找其下的Mapper -->
30     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
31         <property name="basePackage" value="com.yhmp.**.dao "/>
32     </bean>
33     <!-- 配置spring的生命式事务管理 -->
34     <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
35         <property name="dataSource" ref="dataSource"/>
36    </bean>
37    <!--设置注解驱动的事务管理  -->
38    <tx:annotation-driven transaction-manager="txManager"/>
39     
40 </beans>

这是我的mybatis-congfig代码:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
 3 "http://mybatis.org/dtd/mybatis-3-config.dtd">
 4 <configuration>
 5     <settings>
 6           <!-- mybatis控制台LOG输出 -->
 7         <setting name="logImpl" value="LOG4J2" />
 8     </settings>
 9     <!-- 
10     <typeAliases>
11        <typeAlias type="cn.tedu.ttms.product.entity.Team" alias="team"/>
12        <typeAlias type="cn.tedu.ttms.product.entity.Project" alias="project"/>
13     </typeAliases>
14     -->
15     <!-- 
16                  为mapper文件中的参数类型,
17                  返回值类型定义别名
18                  假如是采用package元素定义,
19                  那默认类型的别名为类名并且
20                  第一个单词的首字母小写.
21      -->
22     <typeAliases>
23       <package name="com.yhmp.product.entity"/>
24     </typeAliases>
25 </configuration>

这是我的mapper.xml代码:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 3 <mapper namespace="com.yhmp.product.dao.ProjectPlanDao" >
 4     <insert id="insertmain" parameterType="com.yhmp.product.entity.NameAndLeader" useGeneratedKeys="true" keyProperty="id">
 5         insert into project_plan_main(project_id id,project_name,project_man) 
 6         values(#{id},#{projectName},#{projectLeader});
 7     </insert> 
 8     <insert id="insertstage" parameterType="java.util.ArrayList">
 9         insert into project_plan_stage(plan_stage,plan_content,finish_time,project_staff)
10         values
11         <foreach collection="list" item="workProgramList" open="(" separator="," close=");">
12             #{workProgramList}
13         </foreach>
14     </insert>
15 </mapper>

这是我的测试类:

package product;

import java.util.List;
import java.util.Map;

import org.junit.Test;

import com.yhmp.product.service.ProjectPlanService;

public class Tests
   extends TestBase {

    @Test
    public void test(){
        ProjectPlanService typeService=
        (ProjectPlanService)
        ctx.getBean("projectPlanServiceImpl");
        typeService.insertObject("基础测绘_||_小黄", "计划完成一半&&2017-06-14&&张三,张三,张三,张三,张三,张三_||_计划全部完成&&2017-11-30&&张三,张三,张三,张一");
        
    }
}

这是错误详情:

 1 org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring-pool.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring-pool.xml] cannot be opened because it does not exist
 2     at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
 3     at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
 4     at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
 5     at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
 6     at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
 7     at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)
 8     at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
 9     at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
10     at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
11     at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:614)
12     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:515)
13     at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
14     at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
15     at product.TestBase.init(TestBase.java:15)
16     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
18     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
19     at java.base/java.lang.reflect.Method.invoke(Unknown Source)
20     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
21     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
22     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
23     at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
24     at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
25     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
26     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
27     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
28     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
29     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
30     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
31     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
32     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
33     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
34     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
35     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
36     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539)
37     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761)
38     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461)
39     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)
40 Caused by: java.io.FileNotFoundException: class path resource [spring-pool.xml] cannot be opened because it does not exist
41     at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)
42     at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
43     ... 37 more
44 
45 java.lang.NullPointerException
46     at product.TestBase.destory(TestBase.java:19)
47     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
48     at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
49     at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
50     at java.base/java.lang.reflect.Method.invoke(Unknown Source)
51     at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
52     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
53     at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
54     at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:33)
55     at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
56     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
57     at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
58     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
59     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
60     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
61     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
62     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
63     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
64     at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
65     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
66     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539)
67     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761)
68     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461)
69     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)

这是我的层级目录:

勤劳的杯子的主页 勤劳的杯子 | 初学一级 | 园豆:178
提问于:2017-12-21 16:25
< >
分享
所有回答(3)
0

spring-pool.xml这个配置文件找不到

小淘气儿 | 园豆:124 (初学一级) | 2017-12-22 10:08
0

杯子,ttms是不是精品旅游网站项目

sum墨 | 园豆:429 (菜鸟二级) | 2017-12-28 11:20
0

应该是你的TestBase那个类里面配置的测试类加载的时候加载Spring容器读配置文件。那个里面要截图出来哦,问题应该出在那个类里面。控制台报的错事xml解析错误,找不到文件spring-pool.xml那个文件,你具体看一下是不是TestBase那个类要改一下。

MagicalChopper | 园豆:202 (菜鸟二级) | 2018-01-03 16:50
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册