Maven/Eclipse: Could not find any META-INF/persistence.xml file in the classpath

后端 未结 2 722
难免孤独
难免孤独 2020-12-20 12:52

I know there are other questions on SO about this issue, but none of the solutions have worked for me. I\'m using maven to build a java project in eclipse, and I have my per

相关标签:
2条回答
  • 2020-12-20 13:25

    I put a exclude and the maven stopped to put the persistence.xml. I had to use brutal force to fix:

        <resources>
            <!-- After this maven stopped to put parsistence.xml-->
            <resource>
                <directory>src/main/resources/CATALINA_HOME/conf</directory>
                <excludes>
                    <exclude>log4j.properties</exclude>
                    <exclude>jpa_stocks.properties</exclude>
                </excludes>
            </resource>
            <!-- Brutal force to fix -->
            <resource>
                <directory>src/main/resources/META-INF</directory>
                <targetPath>META-INF</targetPath>
                <includes>
                    <include>persistence.xml</include>
                </includes>
            </resource>
        </resources>
    
    0 讨论(0)
  • 2020-12-20 13:42

    The proper home for the persistence file should be src/main/resources/META-INF. In the question, you mention src/main/resource/META_INF. Note, there should be an 's' in resources and a dash (-) in META-INF, not an underscore. Are those just typos in the question? If not, fix the path and it should work.

    0 讨论(0)
提交回复
热议问题