quickstart maven recognition created less than applicationContext.xml

1, error

maven项目java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be resolve

 2, Description:

Maven project with the quickstart created, configured the Spring xml configuration files, startup error maven project java.io.FileNotFoundException: class path resource [applicationContext.xml] can not be resolve

ApplicationContext appCon = new ClassPathXmlApplicationContext("applicationContext.xml");

 3. Analysis:

classpath maven-quickstart projects by default src / main / java, when we applicationContext.xml placed under src / main / java file, run the correct error "can not find the resources," explained maven package running when there is no will * .xml file in, adding to manually configure the following configuration:

<build>
    ...

    <! - plus follows xml file or document properties to prevent packing when not packaged into maven ->
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
        </includes>
        <filtering>false</filtering>
      </resource>
    </resources>

    ...
</build>

Guess you like

Origin www.cnblogs.com/lkc9/p/12181605.html
Recommended