Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
';xml';将项目从Eclipse迁移到IntelliJ时出现IOException问题_Eclipse_Spring_Ide_Intellij Idea_Runtime Error - Fatal编程技术网

';xml';将项目从Eclipse迁移到IntelliJ时出现IOException问题

';xml';将项目从Eclipse迁移到IntelliJ时出现IOException问题,eclipse,spring,ide,intellij-idea,runtime-error,Eclipse,Spring,Ide,Intellij Idea,Runtime Error,我从另一位同事使用Eclipse创建的TSF中提取了一个Java项目,但是,每当我在IntelliJ中打开该项目时,它都会出现以下运行时异常: 线程“main”中出现异常 org.springframework.beans.factory.BeanDefinitionStoreException: 从类路径资源解析XML文档时发生IOException [spring.xml];嵌套异常为java.io.FileNotFoundException:class 无法打开路径资源[spring.xm

我从另一位同事使用Eclipse创建的TSF中提取了一个Java项目,但是,每当我在IntelliJ中打开该项目时,它都会出现以下运行时异常:

线程“main”中出现异常 org.springframework.beans.factory.BeanDefinitionStoreException: 从类路径资源解析XML文档时发生IOException [spring.xml];嵌套异常为java.io.FileNotFoundException:class 无法打开路径资源[spring.xml],因为它不存在 ... ...

我使用Maven下载了所有项目依赖项,这些依赖项似乎工作得很好,因为我没有收到任何编译时异常

我已经上传了大部分的项目配置设置到这个,希望它能有所帮助


Main.java

ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");

Spring.xml

    <?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:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.3.xsd">

        <bean id="ApplicationConfiguration" class="com.XXX.YYY.ZZZ.ApplicationConfiguration" />
        <bean id="TableFactory" class="com.XXX.YYY.ZZZ.TableFactory">
            <constructor-arg ref="ApplicationConfiguration" />
        </bean>
        <bean id="ItemFactory" class="com.XXX.YYY.ZZZ.datagen.ItemFactory"/>        
        <bean id="ItemWritersPool" class="com.XXX.YYY.ZZZ.ItemWritersPool">        
            <constructor-arg ref="ItemWriterFactory" />
            <constructor-arg ref="ApplicationConfiguration" />
        </bean>
        <bean id="ItemWriterFactory" class="com.XXX.YYY.ZZZ.ItemWriterFactory">
            <constructor-arg ref="ApplicationConfiguration" />
            <constructor-arg ref="TableFactory" />
            <constructor-arg ref="ItemFactory" />
        </bean>
        <bean id="ItemReadersPool" class="com.XXX.YYY.ZZZ.ItemReadersPool">
            <constructor-arg ref="ItemReaderFactory" />
            <constructor-arg ref="ApplicationConfiguration" />
        </bean>
        <bean id="ItemReaderFactory" class="com.XXX.YYY.ZZZ.ItemReaderFactory">
            <constructor-arg ref="TableFactory" />
        </bean>

</beans>
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
  <component name="EclipseModuleManager">
    <conelement value="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" />
    <src_description expected_position="0">
      <src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
    </src_description>
  </component>
  <component name="FacetManager">
    <facet type="Spring" name="Spring">
      <configuration>
        <fileset id="fileset" name="Spring Application Context" removed="false">
          <file>file://$MODULE_DIR$/src/spring.xml</file>
          <file>jar://$MAVEN_REPOSITORY$/io/netty/netty/3.6.3.Final/netty-3.6.3.Final.jar!/org/jboss/netty/container/spring/beans.xml</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/scheduling/annotation/AbstractAsyncConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/cache/annotation/AbstractCachingConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/context/annotation/LoadTimeWeavingConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/context/annotation/MBeanExportConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/scheduling/annotation/ProxyAsyncConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/cache/annotation/ProxyCachingConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/scheduling/annotation/SchedulingConfiguration.class</file>
          <file>file://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar</file>
        </fileset>
      </configuration>
    </facet>
  </component>
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
    <output url="file://$MODULE_DIR$/target/classes" />
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
      <excludeFolder url="file://$MODULE_DIR$/target" />
    </content>
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="inheritedJdk" />
    [-- some items manually removed --]
    <orderEntry type="library" name="Maven: org.springframework:spring-core:3.2.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:3.2.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context:3.2.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:3.2.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:3.2.3.RELEASE" level="project" />
    [-- some items manually removed --]
      </component>
    </module>


Project.iml

    <?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:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.3.xsd">

        <bean id="ApplicationConfiguration" class="com.XXX.YYY.ZZZ.ApplicationConfiguration" />
        <bean id="TableFactory" class="com.XXX.YYY.ZZZ.TableFactory">
            <constructor-arg ref="ApplicationConfiguration" />
        </bean>
        <bean id="ItemFactory" class="com.XXX.YYY.ZZZ.datagen.ItemFactory"/>        
        <bean id="ItemWritersPool" class="com.XXX.YYY.ZZZ.ItemWritersPool">        
            <constructor-arg ref="ItemWriterFactory" />
            <constructor-arg ref="ApplicationConfiguration" />
        </bean>
        <bean id="ItemWriterFactory" class="com.XXX.YYY.ZZZ.ItemWriterFactory">
            <constructor-arg ref="ApplicationConfiguration" />
            <constructor-arg ref="TableFactory" />
            <constructor-arg ref="ItemFactory" />
        </bean>
        <bean id="ItemReadersPool" class="com.XXX.YYY.ZZZ.ItemReadersPool">
            <constructor-arg ref="ItemReaderFactory" />
            <constructor-arg ref="ApplicationConfiguration" />
        </bean>
        <bean id="ItemReaderFactory" class="com.XXX.YYY.ZZZ.ItemReaderFactory">
            <constructor-arg ref="TableFactory" />
        </bean>

</beans>
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
  <component name="EclipseModuleManager">
    <conelement value="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER" />
    <src_description expected_position="0">
      <src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
    </src_description>
  </component>
  <component name="FacetManager">
    <facet type="Spring" name="Spring">
      <configuration>
        <fileset id="fileset" name="Spring Application Context" removed="false">
          <file>file://$MODULE_DIR$/src/spring.xml</file>
          <file>jar://$MAVEN_REPOSITORY$/io/netty/netty/3.6.3.Final/netty-3.6.3.Final.jar!/org/jboss/netty/container/spring/beans.xml</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/scheduling/annotation/AbstractAsyncConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/cache/annotation/AbstractCachingConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/context/annotation/LoadTimeWeavingConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/context/annotation/MBeanExportConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/scheduling/annotation/ProxyAsyncConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/cache/annotation/ProxyCachingConfiguration.class</file>
          <file>jar://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar!/org/springframework/scheduling/annotation/SchedulingConfiguration.class</file>
          <file>file://$MAVEN_REPOSITORY$/org/springframework/spring-context/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar</file>
        </fileset>
      </configuration>
    </facet>
  </component>
  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
    <output url="file://$MODULE_DIR$/target/classes" />
    <output-test url="file://$MODULE_DIR$/target/test-classes" />
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
      <excludeFolder url="file://$MODULE_DIR$/target" />
    </content>
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="inheritedJdk" />
    [-- some items manually removed --]
    <orderEntry type="library" name="Maven: org.springframework:spring-core:3.2.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-beans:3.2.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-context:3.2.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-aop:3.2.3.RELEASE" level="project" />
    <orderEntry type="library" name="Maven: org.springframework:spring-expression:3.2.3.RELEASE" level="project" />
    [-- some items manually removed --]
      </component>
    </module>

文件://$MODULE_DIR$/src/spring.xml
jar://$MAVEN_存储库$/io/netty/netty/3.6.3.Final/netty-3.6.3.Final.jar/org/jboss/netty/container/spring/beans.xml
jar://$MAVEN_REPOSITORY$/org/springframework/springcontext/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar/org/springframework/scheduling/annotation/AbstractAsyncConfiguration.class
jar://$MAVEN_REPOSITORY$/org/springframework/springcontext/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar/org/springframework/cache/annotation/AbstractCachingConfiguration.class
jar://$MAVEN_REPOSITORY$/org/springframework/springcontext/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar/org/springframework/context/annotation/LoadTimeWeavingConfiguration.class
jar://$MAVEN_REPOSITORY$/org/springframework/springcontext/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar/org/springframework/context/annotation/MBeanExportConfiguration.class
jar://$MAVEN_REPOSITORY$/org/springframework/springcontext/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar/org/springframework/scheduling/annotation/proxyanconfiguration.class
jar://$MAVEN_REPOSITORY$/org/springframework/springcontext/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar/org/springframework/cache/annotation/ProxyCachingConfiguration.class
jar://$MAVEN_REPOSITORY$/org/springframework/springcontext/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar/org/springframework/scheduling/annotation/SchedulingConfiguration.class
文件://$MAVEN_REPOSITORY$/org/springframework/springcontext/3.2.3.RELEASE/spring-context-3.2.3.RELEASE.jar
[--手动删除的某些项目--]
[--手动删除的某些项目--]


如有任何建议,将不胜感激。提前谢谢

您的配置中似乎一切正常,因此我使用一个小项目进行了检查,发现问题可能来自您在XML头中使用的冗余名称空间

请尝试为此修改以下内容:

<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.3.xsd">

要产生这样的结果:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

如果不起作用,您还可以通过执行以下操作调整
.iml
文件:

org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=“true”
。您可以通过将
true
替换为
false
来快速测试,并让IntelliJ重新加载您的项目。 我不知道IntelliJ为什么会忽略你的
spring.xml
文件,但是如果你像Maven建议的那样使用两个独立的源和资源目录,你的问题应该会消失

您还应该创建目录
src/main/resources
,并将
spring.xml
文件放在那里


希望这有帮助。

有时这可能是工作目录的问题。这就解释了问题以及如何解决它

IntelliJ与Eclipse的不同之处在于,它将工作目录设置为project根目录,这可能与您正在处理的模块的顶级目录不同

通过将工作目录设置为
$MODULE\u DIR$
,可以在运行配置中修复此问题

如果这有帮助的话,还可以在默认JUnit运行配置中设置工作目录
并修复所有剩余的运行配置。

spring.xml位于src/main/resources?@ThorbjørnRavnAndersen,不在。我试着创建目录并把它放在那里,但没有解决问题。+1,谢谢你的回答。目前不在工作,明天将尝试您的建议,并希望将此问题标记为已回答:)将
isMavenModule
更改为
false
无法解决问题,但您的建议触发了一个想法,最终解决了我面临的问题。我已编辑了您的答案,以包含我的解决方案,因此我可以将其作为答案;)-再次感谢!