VSCODE:java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServlet

Jay Dangar:

我在vscode和spring mvc中发现classpath找不到异常。我尝试了SO上所有可用的解决方案,但没有一个起作用。

[Tomcat 8.5]: Jun 10, 2020 11:09:50 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory [C:\Users\Jay\AppData\Roaming\Code\User\workspaceStorage\48112ea668fdb8e04368dd8a69e48b1e\adashen.vscode-tomcat\tomcat\Tomcat 8.5\webapps\cheruvu-spring]
[Tomcat 8.5]: Jun 10, 2020 11:09:50 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
[Tomcat 8.5]: Jun 10, 2020 11:09:50 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[Tomcat 8.5]: Jun 10, 2020 11:09:50 PM org.apache.catalina.core.ApplicationContext log
INFO: Marking servlet [dispatcher] as unavailable
[Tomcat 8.5]: Jun 10, 2020 11:09:50 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [dispatcher] in web application [/cheruvu-spring] threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:545)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:526)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:985)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4875)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1125)
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1858)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

[Tomcat 8.5]: Jun 10, 2020 11:09:50 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory [C:\Users\Jay\AppData\Roaming\Code\User\workspaceStorage\48112ea668fdb8e04368dd8a69e48b1e\adashen.vscode-tomcat\tomcat\Tomcat 8.5\webapps\cheruvu-spring] has finished in [121] ms

添加我的POM.xml

<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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>cheruvu-spring</groupId>
    <artifactId>cheruvu-spring</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>cheruvu Maven Webapp</name>

    <url>http://maven.apache.org</url>
    <properties>
        <spring.version>4.2.1.RELEASE</spring.version>
        <jackson.version>2.6.2</jackson.version>
        <spring-boot.version>1.2.6.RELEASE</spring-boot.version>
        <filter.name>DEV</filter.name>
        <jersey.version>1.9</jersey.version>
        <base.directory>${basedir}</base.directory>
    </properties>
    <profiles>
        <profile>
            <id>local</id>
            <activation>
                <property>
                    <name>env</name>
                    <value>local</value>
                </property>
            </activation>
            <properties>
                <filter.name>DEV</filter.name>
            </properties>
        </profile>
        <profile>
            <id>dev</id>
            <activation>
                <property>
                    <name>env</name>
                    <value>dev</value>
                </property>
            </activation>
            <properties>
                <filter.name>DEV</filter.name>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <activation>
                <property>
                    <name>env</name>
                    <value>prod</value>
                </property>
            </activation>
            <properties>
                <filter.name>PROD</filter.name>
            </properties>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>4.0.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>



        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>1.8.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>${jersey.version}</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>${jersey.version}</version>
        </dependency>
        <dependency>
            <groupId>net.kencochrane.raven</groupId>
            <artifactId>raven-log4j2</artifactId>
            <version>6.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>19.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-csv</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>com.github.spullara.mustache.java</groupId>
            <artifactId>compiler</artifactId>
            <version>0.8.15</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.354</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>com.flipkart.zjsonpatch</groupId>
            <artifactId>zjsonpatch</artifactId>
            <version>0.2.3</version>
        </dependency>
        <dependency>
            <groupId>eu.bitwalker</groupId>
            <artifactId>UserAgentUtils</artifactId>
            <version>1.20</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-sns</artifactId>
            <version>1.11.354</version>
        </dependency>
    </dependencies>
    <build>
        <!-- <filters> <filter>${basedir}/src/main/resources/ENV-${filter.name}/application.properties</filter> 
            </filters> -->
        <finalName>cheruvu-spring</finalName>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                        <debug>true</debug>
                        <debuglevel>source,lines</debuglevel>
                        <showDeprecation>true</showDeprecation>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <systemPropertyVariables>
                            <environment>prod</environment>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.google.code.maven-svn-revision-number-plugin</groupId>
                    <artifactId>maven-svn-revision-number-plugin</artifactId>
                    <version>1.7</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>revision</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <entries>
                            <entry>
                                <prefix>svn</prefix>
                            </entry>
                        </entries>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>buildnumber-maven-plugin</artifactId>
                    <version>1.0</version>
                    <executions>
                        <execution>
                            <id>generate-timestamp</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>create-timestamp</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <format>{0,date,yyyy-MM-dd HH:mm}</format>
                        <items>
                            <item>timestamp</item>
                        </items>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
</project>
Jay Dangar:

我已经找到了解决方法。VSCode已经为该项目生成了.war文件,我已经将文件手动复制到了Tomcat服务器的webapp目录中,然后再次启动了该服务器。Tomcat已成功加载了Webapp,并且API开始起作用,我不知道是否存在依赖关系问题,但是此解决方案对我来说有效。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

来自分类Java

问题-java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServlet

来自分类Java

错误[org.springframework.web.servlet.DispatcherServlet]

来自分类Java

引起原因:java.lang.ClassNotFoundException:org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer

来自分类Java

java.lang.ClassNotFoundException:org.springframework.web.servlet.support.DefaultFlashMapManager Weblogic 12c

来自分类Dev

java.lang.ClassNotFoundException:org.springframework.web.context.ContextLoaderListener

来自分类Dev

从Spring 3.0迁移到Spring 3.1时org.springframework.web.servlet.DispatcherServlet错误

来自分类Java

java.lang.ClassNotFoundException:org.springframework.core.io.Resource

来自分类Java

java.lang.ClassNotFoundException:org.springframework.boot.SpringApplication Maven

来自分类Dev

java.lang.ClassNotFoundException:org.springframework.context.ApplicationContextInitializer

来自分类Java

java.lang.ClassNotFoundException:org.glassfish.jersey.servlet.ServletContainer

来自分类Dev

我在Tomcat Webb应用程序中收到java.lang.ClassNotFoundException:org.springframework.web.context.WebApplicationContext

来自分类Dev

春季:java.lang.ClassNotFoundException:找不到org.springframework.boot.SpringApplication

来自分类Java

抛出java.lang.ClassNotFoundException:org.springframework.boot.context.properties.bind.Bindable

来自分类Java

引起原因:java.lang.ClassNotFoundException:org.springframework.integration.dsl.IntegrationFlowBuilder

来自分类Java

Gradle项目错误-java.lang.ClassNotFoundException:org.springframework.boot.SpringApplication

来自分类Java

Servlet:java.lang.ClassNotFoundException:org.json.simple.parser.ParseException

来自分类Java

春天卡夫卡错误产生的原因:抛出java.lang.ClassNotFoundException:org.springframework.kafka.transaction.KafkaAwareTransactionManager

来自分类Java

Spring Boot 1.4.2.RELEASE错误在启动java.lang.ClassNotFoundException:org.springframework.beans.factory.ObjectProvider

来自分类Dev

org.apache.commons.lang.SerializationException:java.lang.ClassNotFoundException

来自分类Java

如何解决“ weblogic.application.ModuleException:java.lang.ClassNotFoundException:org.glassfish.jersey.servlet.ServletContainer”错误

来自分类Java

java.lang.ClassNotFoundException:org.jooq.util.JavaGenerator

来自分类Dev

java.lang.ClassNotFoundException:org.apache.commons.digester.Rule

来自分类Java

java.lang.ClassNotFoundException:org.codehaus.jackson.map.JsonSerializableWithType

来自分类Java

java.lang.ClassNotFoundException:org.apache.xmlbeans.XmlException

来自分类Java

java.lang.ClassNotFoundException:org.apache.pdfbox.multipdf.PDFMergerUtility

来自分类Java

java.lang.ClassNotFoundException:org.apache.xmlbeans.XmlObject错误

来自分类Java

java.lang.ClassNotFoundException:org.apache.commons.text.WordUtils

来自分类Java

java.lang.ClassNotFoundException:org.eclipse.jetty.Server

来自分类Dev

Eclipse java.lang.ClassNotFoundException

TOP 榜单

热门标签

归档