Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 弹簧靴&x2B;ApacheCXF for soap web服务_Java_Spring_Spring Boot_Soap_Cxf - Fatal编程技术网

Java 弹簧靴&x2B;ApacheCXF for soap web服务

Java 弹簧靴&x2B;ApacheCXF for soap web服务,java,spring,spring-boot,soap,cxf,Java,Spring,Spring Boot,Soap,Cxf,我一直在做弹簧靴。我遵循这个示例,尝试使用创建一个简单的soapweb服务。 在跟踪整个样本之后。我在运行应用程序时遇到了一个问题。下面是错误的堆栈跟踪 2017-09-09 20:06:59.883 ERROR 7302 --- [ main] o.s.boot.SpringApplication : Application startup failed java.lang.NoClassDefFoundError: org/springfra

我一直在做弹簧靴。我遵循这个示例,尝试使用创建一个简单的soapweb服务。 在跟踪整个样本之后。我在运行应用程序时遇到了一个问题。下面是错误的堆栈跟踪

2017-09-09 20:06:59.883 ERROR 7302 --- [           main] o.s.boot.SpringApplication               : Application startup failed

java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/ServletRegistrationBean
    at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_121]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_121]
    at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_121]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) ~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524) ~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510) ~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570) ~[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:425) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at com.posts.PostApplication.main(PostApplication.java:10) [classes/:na]
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.ServletRegistrationBean
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_121]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_121]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_121]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_121]
    ... 23 common frames omitted

2017-09-09 20:06:59.884  INFO 7302 --- [           main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6dbb137d: startup date [Sat Sep 09 20:06:58 PKT 2017]; root of context hierarchy
2017-09-09 20:06:59.885  WARN 7302 --- [           main] 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@6dbb137d: startup date [Sat Sep 09 20:06:58 PKT 2017]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:427) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:999) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at com.posts.PostApplication.main(PostApplication.java:10) [classes/:na]

2017-09-09 20:06:59.886 ERROR 7302 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6dbb137d: startup date [Sat Sep 09 20:06:58 PKT 2017]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:414) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.destroySingletons(FactoryBeanRegistrySupport.java:230) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) [spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1030) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1006) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958) [spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE]
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE]
    at com.posts.PostApplication.main(PostApplication.java:10) [classes/:na]

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/ServletRegistrationBean
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
    at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
    at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609)
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:425)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:515)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:508)
    at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1186)
    at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:818)
    at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:804)
    at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:790)
    at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:744)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at com.posts.PostApplication.main(PostApplication.java:10)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.ServletRegistrationBean
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 24 more

Process finished with exit code 1
我想在SpringBoot中创建一个简单的SOAPWeb服务。为此,我使用apachecfx


这是pom.xml文件

org.springframework.boot.context.embedded.ServletRegistrationBean
已从Spring版本
1.5.x
中删除。该错误是由org.apache.cxf的版本引起的。。cxf spring boot starter jaxws
3.1.7
,因为它取决于从SB
1.5.x
中删除的
org.spri…embedded.ServletRegistrationBean

只需将
org.apache.cxf cxf spring boot starter jaxws
依赖项更新到与SB兼容的版本
1.5.x

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
        <version>3.1.11</version>
    </dependency>
一旦添加了Spring安全依赖项,Spring boot将自动使用http基本身份验证保护所有http端点。如果需要自定义此配置,以下是一个示例:

创建一个
@Configuration
类,该类从
websecurityConfigureAdapter
扩展并重写configure方法,以便配置身份验证和授权过程:如下所示

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {

        //credentials and roles to use
        auth.inMemoryAuthentication().withUser("soapuser").password("secret").roles("ADMIN");

    }

    @Override
    public void configure(HttpSecurity http) throws Exception{

        //this configuration define that every request is authorized only to Admin roles and authenticated users.
        http
                .authorizeRequests()
                .anyRequest()
                .hasRole("ADMIN")
                .anyRequest()
                .authenticated()

                //this configuration define an http basic authentication
                .and().httpBasic()

                //disable csfr
                .and().csrf().disable();
    }

}
最后,我建议始终在https上执行http基本身份验证,这可以通过
应用程序来完成。属性
配置:

server.port=9443
server.ssl.enabled=true
server.ssl.key-store=classpath:keystore.jks
server.ssl.key-store-password=changeit
server.ssl.key-password=changeit
在本例中,应用程序将在9443端口上通过https运行
https://localhost:9443/


本文列出了通过SpringSecurity保护ApacheCxf的其他替代方案。我还更新了git repo,以展示如何使用spring boot和apache cxf实现spring安全性的示例。

org.springframework.boot.context.embedded.ServletRegistrationBean
已从spring版本
1.5.x
中删除。该错误是由org.apache.cxf的版本引起的。。cxf spring boot starter jaxws
3.1.7
,因为它取决于从SB
1.5.x
中删除的
org.spri…embedded.ServletRegistrationBean

只需将
org.apache.cxf cxf spring boot starter jaxws
依赖项更新到与SB兼容的版本
1.5.x

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-spring-boot-starter-jaxws</artifactId>
        <version>3.1.11</version>
    </dependency>
一旦添加了Spring安全依赖项,Spring boot将自动使用http基本身份验证保护所有http端点。如果需要自定义此配置,以下是一个示例:

创建一个
@Configuration
类,该类从
websecurityConfigureAdapter
扩展并重写configure方法,以便配置身份验证和授权过程:如下所示

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {

        //credentials and roles to use
        auth.inMemoryAuthentication().withUser("soapuser").password("secret").roles("ADMIN");

    }

    @Override
    public void configure(HttpSecurity http) throws Exception{

        //this configuration define that every request is authorized only to Admin roles and authenticated users.
        http
                .authorizeRequests()
                .anyRequest()
                .hasRole("ADMIN")
                .anyRequest()
                .authenticated()

                //this configuration define an http basic authentication
                .and().httpBasic()

                //disable csfr
                .and().csrf().disable();
    }

}
最后,我建议始终在https上执行http基本身份验证,这可以通过
应用程序来完成。属性
配置:

server.port=9443
server.ssl.enabled=true
server.ssl.key-store=classpath:keystore.jks
server.ssl.key-store-password=changeit
server.ssl.key-password=changeit
在本例中,应用程序将在9443端口上通过https运行
https://localhost:9443/


本文列出了通过SpringSecurity保护ApacheCxf的其他替代方案。我还更新了git repo,以展示如何使用spring boot和apache cxf实现spring安全性的示例。

如果使用spring boot 1.5及更高版本,这是一个不兼容的问题。您需要使用最新版本的cxf:

compile 'org.grails.plugins:cxf:3.1.2'
这个版本解决了我的问题:

NoClassDefFoundError: org/springframework/boot/context/embedded/ServletRegistrationBean

回答Grails项目中的bsed。

这是一个不兼容问题,如果您使用的是spring boot 1.5及更高版本,则会发生此问题。您需要使用最新版本的cxf:

compile 'org.grails.plugins:cxf:3.1.2'
这个版本解决了我的问题:

NoClassDefFoundError: org/springframework/boot/context/embedded/ServletRegistrationBean

回答Grails项目中的bsed。

似乎
pom.xml
依赖项有错误,您能否共享项目的
pom.xml
?我创建了一个类似的项目,但是我必须相应地将
pom.xml
更改为来自的当前版本。这是pom.xml文件。似乎
pom.xml
依赖项有错误,您能否共享项目的
pom.xml
?我创建了一个类似的项目,但是我必须相应地将
pom.xml
更改为来自的当前版本。这是pom.xml文件。谢谢,您曾经使用spring安全性保护过soap api吗?您好,我只是添加了与安全性相关的新信息,您也可以查看git repo中的一个示例。基本上,我想使用基于令牌的身份验证来保护我的soap api。不能只启用安全性。谢谢,你曾经使用spring安全性保护过soap api吗?您好,我只是添加了与安全性相关的新信息,您也可以查看git repo中的一个示例。基本上,我想使用基于令牌的身份验证来保护我的soap api。不能只启用安全性。