java - Spring boot web war - web-inf/classes/context.xml file not found -
When I put a Spring Boot based project on tomac, the server persistence-context.xml
Which is under Web-NF / Class
. I received the error on the badge console
java.io.FileNotFoundException: Open ServletContext resource [/persistence-context.xml]
I did the following The structure of the Spring Boot WS application could be:
src / main / java / hello / application.java HelloWebXml.java src / main / resource / persistence- context.xml
after my classes
@ComponentScan ("foo.bla.bar") @ImportResource ("classpath: persistence context.xml") @Configuration @EnableAutoConfiguration public class Application {public static zero main (last string [] r GSA) {SpringApplication.run (application.class, args); }}
After the WebXml class is doing.
Public class HelloWebXml extends SpringBootServletInitializer {@Override Protected SpringApplicationBuilder Configure (Last SpringApplicationBuilder Application) {application.sources Return (application.class); }}
The following is my pom.xml
file
& lt; Project xmlns = "http: // maven.apache .org / pom / 4.0.0" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http: // Maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> & Lt; ModelVersion & gt; 4.0.0 & lt; / ModelVersion & gt; & Lt; Group & gt; Org.foo.bar & lt; / Group & gt; & Lt; ArtifactId & gt; Bar-ws & lt; / ArtifactId> & Lt; Version & gt; 0.0.1-snapshot and lt; / Edition & gt; & Lt; Packaging & gt; War & lt; / Packaging & gt; & Lt; Parents & gt; & Lt; Group & gt; Org.springframework.boot & lt; / Group & gt; & Lt; ArtifactId & gt; Spring-boot starter parents & lt; / ArtifactId> & Lt; Version & gt; 1.1.4.RELEASE & lt; / Edition & gt; & Lt; / Parent & gt; & Lt; Dependency & gt; & Lt; Dependency & gt; & Lt; Group & gt; Org.springframework.boot & lt; / Group & gt; & Lt; ArtifactId & gt; Spring-boot starter-web & lt; / ArtifactId> & Lt; / Dependencies & gt; & Lt; / Dependencies & gt; & Lt; Properties & gt; & Lt; Start level & gt; Bla.bar.Application & lt; / Start level & gt; & Lt; / Properties & gt; & Lt; Construction & gt; & Lt; Plugins & gt; & Lt; Plugin & gt; & Lt; ArtifactId & gt; Maven-compliant plugin & lt; / ArtifactId> & Lt; / Plugin & gt; & Lt; Plugin & gt; & Lt; Group & gt; Org.springframework.boot & lt; / Group & gt; & Lt; ArtifactId & gt; Spring-boot-Maven-plugin & lt; / ArtifactId> & Lt; / Plugin & gt; & Lt; / Plugins & gt; & Lt; / Create & gt; & Lt; / Project & gt;
I am creating a war file of this project. Can anyone please guide me how to fix this?
Comments
Post a Comment