我正在使用 Spring 和 Spring Security 开发 Java 8 Web应用程序。我的IDE是 Intellij IDEA Ultimate ,该应用程序已与Intellij一起部署到 Tomcat 8.5 。构建过程使用两个Maven配置文件。如果我尝试通过Intellij Tomcat运行配置启动应用程序,有时(并非每次都很奇怪)(对于每次target\webapp\WEB-INF\lib\
),我都会得到 FileNotFoundExceptions 。
ErrorStack示例:
17-May-2019 13:23:11.715 SCHWERWIEGEND [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.catalina.core.StandardContext.reload Exception starting Context with name [/collphir]
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/collphir]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3839)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:291)
at org.apache.catalina.core.StandardContext.backgroundProcess(StandardContext.java:5612)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1389)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1393)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1393)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1361)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: java.io.FileNotFoundException: C:\GITROOT\adesso\collphir4_backend\target\webapp\WEB-INF\lib\spring-data-jpa-1.11.1.RELEASE.jar (Das System kann die angegebene Datei nicht finden)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.isMultiRelease(AbstractSingleArchiveResourceSet.java:121)
at org.apache.catalina.webresources.AbstractArchiveResourceSet.getResource(AbstractArchiveResourceSet.java:250)
at org.apache.catalina.webresources.StandardRoot.getResourcesInternal(StandardRoot.java:327)
at org.apache.catalina.webresources.CachedResource.validateResources(CachedResource.java:140)
at org.apache.catalina.webresources.Cache.getResources(Cache.java:147)
at org.apache.catalina.webresources.StandardRoot.getResources(StandardRoot.java:315)
at org.apache.catalina.webresources.StandardRoot.getClassLoaderResources(StandardRoot.java:231)
at org.apache.catalina.util.ExtensionValidator.validateApplication(ExtensionValidator.java:146)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5062)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 8 more
Caused by: java.io.FileNotFoundException: C:\GITROOT\adesso\collphir4_backend\target\webapp\WEB-INF\lib\spring-data-jpa-1.11.1.RELEASE.jar (Das System kann die angegebene Datei nicht finden)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:225)
at java.util.zip.ZipFile.<init>(ZipFile.java:155)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:196)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:181)
at org.apache.catalina.webresources.AbstractArchiveResourceSet.openJarFile(AbstractArchiveResourceSet.java:308)
at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.isMultiRelease(AbstractSingleArchiveResourceSet.java:116)
... 17 more
答案 0 :(得分:0)
在您的pom.xml中添加jar依赖项-
Dependencies : add dependency in your pom.xml
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.11.1.RELEASE</version>
</dependency>
Build Configuration :
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<!--<skipMain>true</skipMain> -->
<skip>true</skip>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>target/jacoco.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<outputDirectory>target/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>