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

标签 spring nosuchmethoderror

我正在测试我的第一个 Spring 项目。我正在尝试调用网络服务。我正在按照此处列出的教程进行操作:http://spring.io/guides/gs/consuming-web-service/

当我尝试构建我的项目时,出现以下错误:

2014-09-08 15:10:38.924  INFO 4736 --- [           main] b.i.einvoice.webserviceTest.TestMain     : Starting TestMain on W7-010545 with PID 4736 (C:\Users\staelko\git\einvoice-portlets\einvoice\target\classes started by staelko in C:\Users\staelko\git\einvoice-portlets\einvoice)
2014-09-08 15:10:38.978  INFO 4736 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@12d56b37: startup date [Mon Sep 08 15:10:38 CEST 2014]; root of context hierarchy
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.web.context.support.ServletContextAwareProcessor: method <init>()V not found

这是什么原因造成的?

我的 POM:
<?xml version="1.0"?>

<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>be.icredit</groupId>
    <artifactId>einvoice</artifactId>
    <packaging>war</packaging>
    <name>einvoice Portlet</name>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <liferay.maven.plugin.version>6.2.10.6</liferay.maven.plugin.version>
        <liferay.version>6.2.1</liferay.version>
        <spring.suite.version>3.2.10.RELEASE</spring.suite.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>com.liferay.maven.plugins</groupId>
                <artifactId>liferay-maven-plugin</artifactId>
                <version>${liferay.maven.plugin.version}</version>
                <executions>

                </executions>
                <configuration>
                    <autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
                    <appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
                    <appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
                    <appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
                    <liferayVersion>${liferay.version}</liferayVersion>
                    <pluginType>portlet</pluginType>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.5</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.9.0</version>

                <executions>
                    <execution>
                        <id>BatchDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.BatchDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>BatchDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>CustomerAccountDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.CustomerAccountDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>CustomerAccountDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>CustomerDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.CustomerDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>CustomerDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>DocumentDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.DocumentDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>DocumentDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>DocumentTemplateDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.DocumentTemplateDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>DocumentTemplateDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>EmailStatusDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.EmailStatusDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>EmailStatusDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>EmailTemplateDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.EmailTemplateDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>EmailTemplateDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>FileService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.FileService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>FileService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                    <execution>
                        <id>SenderDaoService-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <generatePackage>be.icredit.einvoice.proxy.SenderDaoService</generatePackage>
                            <forceRegenerate>true</forceRegenerate>
                            <schemas>
                                <schema>
                                    <fileset>
                                        <!-- Defaults to schemaDirectory -->
                                        <directory>${basedir}/src/main/resources/wsdl/</directory>
                                        <!-- Defaults to schemaIncludes -->
                                        <includes>
                                            <include>SenderDaoService.wsdl</include>
                                        </includes>
                                    </fileset>
                                </schema>
                            </schemas>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>portal-service</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-bridges</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-taglib</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.liferay.portal</groupId>
            <artifactId>util-java</artifactId>
            <version>${liferay.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>${spring.suite.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>1.1.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>



    </dependencies>
</project>

下面的完整堆栈跟踪:
 :: Spring Boot ::        (v1.1.6.RELEASE)

2014-09-08 15:26:06.200  INFO 2964 --- [           main] b.i.einvoice.webserviceTest.TestMain     : Starting TestMain on W7-010545 with PID 2964 (C:\Users\staelko\git\einvoice-portlets\einvoice\target\classes started by staelko in C:\Users\staelko\git\einvoice-portlets\einvoice)
2014-09-08 15:26:06.273  INFO 2964 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@326b9c84: startup date [Mon Sep 08 15:26:06 CEST 2014]; root of context hierarchy
Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.web.context.support.ServletContextAwareProcessor: method <init>()V not found
    at org.springframework.boot.context.embedded.WebApplicationContextServletContextAwareProcessor.<init>(WebApplicationContextServletContextAwareProcessor.java:40)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.postProcessBeanFactory(EmbeddedWebApplicationContext.java:100)
    at org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext.postProcessBeanFactory(AnnotationConfigEmbeddedWebApplicationContext.java:180)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:458)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
    at be.icredit.einvoice.webserviceTest.TestMain.main(TestMain.java:13)
2014-09-08 15:26:06.307  INFO 2964 --- [       Thread-1] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@326b9c84: startup date [Mon Sep 08 15:26:06 CEST 2014]; root of context hierarchy
2014-09-08 15:26:06.319  WARN 2964 --- [       Thread-1] ationConfigEmbeddedWebApplicationContext : Exception thrown from ApplicationListener handling ContextClosedEvent

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@326b9c84: startup date [Mon Sep 08 15:26:06 CEST 2014]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:141)
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:980)

2014-09-08 15:26:06.320  WARN 2964 --- [       Thread-1] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close

java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@326b9c84: startup date [Mon Sep 08 15:26:06 CEST 2014]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.doClose(EmbeddedWebApplicationContext.java:141)
    at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:980)

2014-09-08 15:26:06.321  INFO 2964 --- [       Thread-1] o.s.b.f.s.DefaultListableBeanFactory     : Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@331c89c: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,customerDaoConfiguration]; root of factory hierarchy

在我的主类中的这一行上,应用程序崩溃了:
ApplicationContext ctx = SpringApplication.run(CustomerDaoConfiguration.class, args);

我的 CustomerDaoConfiguration 如下所示:
@Configuration
public class CustomerDaoConfiguration {

    @Bean
    public Jaxb2Marshaller marshaller() {
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
        marshaller.setContextPath("be.icredit.einvoice.proxy.CustomerDaoService");
        return marshaller;
    }

    @Bean
    public CustomerClient weatherClient(Jaxb2Marshaller marshaller) {
        CustomerClient client = new CustomerClient();
        client.setDefaultUri("http://ws08-icreditlc.iconos.be:18080/icredit-service-data/CustomerDaoService");
        client.setMarshaller(marshaller);
        client.setUnmarshaller(marshaller);
        return client;
    }

}

最佳答案

你在使用 IDE 吗?我在使用 IntelliJ 时遇到了完全相同的问题,但是当我从终端运行它时

 mvn  spring-boot:run

它会运行良好。为了让它在 IntelliJ 中工作,我必须转到“项目结构”->“模块”->“依赖项”并移动资源或手动将它们移动到 .iml 文件中。

来自 Spring 文档:
IntelliJ IDEA orders the classpath differently depending on how you run your application. Running your application in the IDE via its main method will result in a different ordering to when you run your application using Maven or Gradle or from its pacakaged jar. This can cause Spring Boot to fail to find the templates on the classpath. If you’re affected by this problem you can reorder the classpath in the IDE to place the module’s classes and resources first. Alternatively, you can configure the template prefix to search every templates directory on the classpath: classpath*:/templates/.

关于spring - java.lang.NoSuchMethodError : org. springframework.web.context.support.ServletContextAwareProcessor:方法 <init>()V 未找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25725175/

相关文章:

java - 为什么这个具有基于 java 的配置的 Spring 应用程序不能正常工作

spring-boot - 带有 Spring Boot 和 gradle 的 flyway--org.flywaydb.core.Flyway : method <init>()V not found

JQuery 将 JSON 发送到 Spring MVC Controller

JAVA:RMI 方法错误:java.lang.NoSuchMethodError

android - 按钮 onClick 的 NoSuchMethod 异常

java - 一台机器上出现 NoSuchMethodError,但另一台机器上没有

java - newInstance() 找不到存在的构造函数

spring - com.mongodb.async.client.ClientSessionHelpe 没有从集群描述 ClusterDescription 选择服务器

java - @Transactional测试中未填充联接表

spring - 有什么方法可以阻止springfox Swagger 地扫描模型类吗?