我在执行maven compile的时候发生了一个很奇怪的问题,在src\main\java下的源代码中 写的spring的配置文件和ibatis的map文件都没有拷贝到target/classes 目录里去很不知道为什么。有哪位高手遇见过这样问题?

解决方案 »

  1.   

    因为maven会过滤src/main/java里的文件,只有.class文件会被拷贝到classpath下。根据你的描述,我猜测你是用的maven2(因为maven2建立的文件结构是src/main/java),如果是maven2的话,默认的配置文件夹是src/main/resources/,在这个目录下的文件和文件夹都会被拷贝到classpath里去。试试把你的spring和ibatis配置文件放到这里,再运行maven compile.如果你是用的maven1, 你需要在maven.xml里定义一个goal来拷贝需要的文件类型,路径,和目标路径,例如:
    <goal name="copyConfig.files" description="copy configuration files needed">
        <copy file="${basedir}/src/resources/log4j/log4j.properties" 
            todir="${basedir}/target/classes"/>
     
        <copy file="${basedir}/src/resources/spring/applicationContext.xml" 
            todir="${basedir}/target/classes/"/>  
    </goal>