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

伊亚斯·阿尔塔维尔(Iyas Altawil)

当我运行Spring Web Maven项目时出现以下错误

SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

在我将另一个项目导入Eclipse之前,该项目运行良好。

我尝试了Web中的所有解决方案(部署程序集,Tomcat库类路径,Clean Tomcat Work目录,maven-compiler-plugin版本)。

但是,当我导出战争文件并将其上传到云(弹性)文件时,效果很好!

这是pom.xml

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java-version>1.6</java-version>
    <org.springframework-version>4.0.6.RELEASE</org.springframework-version>
    <org.aspectj-version>1.6.10</org.aspectj-version>
    <org.slf4j-version>1.6.6</org.slf4j-version>
    <mysql.connector.version>5.1.30</mysql.connector.version>
    <jackson.databind-version>2.2.3</jackson.databind-version>
    <spring.security.version>3.2.3.RELEASE</spring.security.version>
</properties>
<dependencies>
    <!-- Spring -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework-version}</version>
        <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework-version}</version>
    </dependency>


    <!-- AspectJ -->
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${org.aspectj-version}</version>
    </dependency>

    <!-- Logging -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.15</version>
        <exclusions>
            <exclusion>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
        </exclusions>
        <scope>runtime</scope>
    </dependency>

    <!-- @Inject -->
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <!-- Servlet -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- Test -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.7</version>
        <scope>test</scope>
    </dependency>

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

    <!-- connect to mysql -->
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>${mysql.connector.version}</version>
    </dependency>

    <!-- Jackson -->
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson.databind-version}</version>
    </dependency>

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

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

    <!-- Spring Security JSP Taglib -->
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-taglibs</artifactId>
        <version>${spring.security.version}</version>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.0.1.Final</version>
    </dependency>

    <dependency>
        <groupId>org.ocpsoft.prettytime</groupId>
        <artifactId>prettytime</artifactId>
        <version>3.2.5.Final</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <additionalProjectnatures>
                    <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                </additionalProjectnatures>
                <additionalBuildcommands>
                    <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                </additionalBuildcommands>
                <downloadSources>true</downloadSources>
                <downloadJavadocs>true</downloadJavadocs>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArgument>-Xlint:all</compilerArgument>
                <showWarnings>true</showWarnings>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <configuration>
                <mainClass>org.test.int1.Main</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>
斯基佐

在pom.xml中添加以下依赖项

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

更新1

也将此添加到您的pom.xml中

 <!-- To launch embded jetty server -->
    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>${maven-jetty-plugin.version}</version>
    </plugin>

并使用mvn jetty运行您的应用程序:运行,看看问题是否仍然存在

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

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

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

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

找不到org.springframework.web.context.ContextLoaderListener类

Tomcat和Spring Web-找不到类异常org.springframework.web.context.ContextLoaderListener

严重:错误配置类 [org.springframework.web.context.ContextLoaderListener] NoClassDefFoundError: javax/servlet/ServletContextListener

引起原因:java.lang.ClassNotFoundException:org.springframework.web.context.request.RequestAttributes

Spring MVC Webapp-java.lang.ClassNotFoundException:org.springframework.web.context.support.ServletRequestHandledEvent

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

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

java.lang.NoClassDefFoundError:org / springframework / web / context / ContextCleanupListener问题

找不到类org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer

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

引起:java.lang.ClassNotFoundException:org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata

ClassNotFoundException: org/springframework/context/support/LiveBeansView 异常在 STS 中重复抛出

在春季解决java.lang.ClassNotFoundException:org.springframework.context.ApplicationListener异常

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

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

Tomcat,java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServlet

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

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

ClassNotFoundException:org.springframework.jdbc.datasource.DriverManagerDataSource

java.lang.NoSuchMethodError:org.springframework.web.context.request.ServletRequestAttributes。<init>

java.lang.NoSuchMethodError:org.springframework.web.context.support.ServletContextAwareProcessor:方法<init>()V未找到

无法初始化类org.springframework.web.context.request.ServletRequestAttributes

错误:org.springframework.web.context.ContextLoader - 上下文初始化失败 [context-security.xml]

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

ClassNotFoundException:org.springframework.http.converter.json.MappingJacksonHttpMessageConverter

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

Java MongoDB ClassNotFoundException:org.springframework.data.convert.CollectionFactory

加载ContextLoaderListener时发生ClassNotFoundException