0

我有一组正在开发的微服务。在 Maven 中开发一切正常。

(1) REGISTRY:我有一个 jhipster-registery 在开发配置文件中运行,配置为 at git。它工作正常,我可以看到我的自定义配置。

./jhipster-registry-3.2.3.war --security.user.password=admin --jhipster.security.authentication.jwt.secret=my-secret-token-to-change-in-production2 --spring.profiles.active=dev --spring.cloud.config.server.git.uri=ssh://myuser@mygit.mycustomdomain.org/git/dev/microservices/registryconfig.git

(2) UAA:我有一个由 maven (./mvnw) 和打包的 war 文件启动的 uaa。它在注册表中注册为成员。当我测试其他微服务时,它可以成功运行。我先启动这个。

-- 20180317-附加更新:网关在打包为war 文件时运行良好。所以只有我的微服务有问题。

(3) 带有 MAVEN 的 MICROSERVICE:当我使用带有开发配置文件的 ./mvnw 启动我的称为调度程序的微服务时,它成功启动,没有任何问题,并且以编程方式正常运行。所以我会假设一旦我把它打包成一个war文件,它的工作方式就完全一样了。

(4) 带有打包开发 WAR 的 MICROSERVICE 失败。:当我使用打包的war文件 ./mvnw -Pdev 包在maven之外测试微服务时,然后启动./target/dispatcher/dispatcher-0.0.1-SNAPSHOT.war它失败的war文件


上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration . class]: init 方法调用失败;嵌套异常是 java.lang.IllegalArgumentException:需要 AuthenticationManager

我不知道这是实际问题还是与关闭有关。

非常感谢您的帮助。

---------------------------------------------------------
:: JHipster   :: Running Spring Boot 1.5.9.RELEASE ::
:: http://www.jhipster.tech ::

2018-03-16 20:53:03.442  INFO 3886 --- [           main] o.l.services.dispatcher.DispatcherApp    : The following profiles are active: swagger,dev
2018-03-16 20:53:11.741 DEBUG 3886 --- [           main] o.l.s.d.config.AsyncConfiguration        : Creating Async Task Executor
2018-03-16 20:53:12.767 DEBUG 3886 --- [           main] o.l.s.d.config.MetricsConfiguration      : Registering JVM gauges
2018-03-16 20:53:12.822 DEBUG 3886 --- [           main] o.l.s.d.config.MetricsConfiguration      : Monitoring the datasource
2018-03-16 20:53:12.822 DEBUG 3886 --- [           main] o.l.s.d.config.MetricsConfiguration      : Initializing Metrics JMX reporting
2018-03-16 20:53:14.015 DEBUG 3886 --- [           main] o.l.s.d.config.CacheConfiguration        : Configuring Hazelcast
2018-03-16 20:53:14.071 DEBUG 3886 --- [           main] o.l.s.d.config.CacheConfiguration        : Configuring Hazelcast clustering for instanceId: dispatcher
2018-03-16 20:53:14.073 DEBUG 3886 --- [           main] o.l.s.d.config.CacheConfiguration        : Application is running with the "dev" profile, Hazelcast cluster will only work with localhost instances
2018-03-16 20:53:14.211  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2018-03-16 20:53:14.560  INFO 3886 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2018-03-16 20:53:14.560  INFO 3886 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2018-03-16 20:53:14.793  INFO 3886 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2018-03-16 20:53:14.797  INFO 3886 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2018-03-16 20:53:15.110  INFO 3886 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2018-03-16 20:53:15.151  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2018-03-16 20:53:15.152  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2018-03-16 20:53:15.152  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2018-03-16 20:53:15.152  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2018-03-16 20:53:15.153  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2018-03-16 20:53:15.153  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2018-03-16 20:53:15.153  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2018-03-16 20:53:15.360  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2018-03-16 20:53:15.362  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 5
2018-03-16 20:53:15.369  INFO 3886 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 12
2018-03-16 20:53:15.372  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1521233595372 with initial instances count: 1
2018-03-16 20:53:15.488  INFO 3886 --- [           main] com.hazelcast.instance.AddressPicker     : [LOCAL] [dev] [3.9.1] Picked [127.0.0.1]:15703, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=15703], bind any local is true
2018-03-16 20:53:15.526  INFO 3886 --- [           main] com.hazelcast.system                     : [127.0.0.1]:15703 [dev] [3.9.1] Hazelcast 3.9.1 (20171130 - feca534) starting at [127.0.0.1]:15703
2018-03-16 20:53:15.526  INFO 3886 --- [           main] com.hazelcast.system                     : [127.0.0.1]:15703 [dev] [3.9.1] Copyright (c) 2008-2017, Hazelcast, Inc. All Rights Reserved.
2018-03-16 20:53:15.526  INFO 3886 --- [           main] com.hazelcast.system                     : [127.0.0.1]:15703 [dev] [3.9.1] Configured Hazelcast Serialization version: 1
2018-03-16 20:53:16.217  INFO 3886 --- [           main] c.h.s.i.o.impl.BackpressureRegulator     : [127.0.0.1]:15703 [dev] [3.9.1] Backpressure is disabled
2018-03-16 20:53:17.621  INFO 3886 --- [           main] com.hazelcast.instance.Node              : [127.0.0.1]:15703 [dev] [3.9.1] Creating TcpIpJoiner
2018-03-16 20:53:18.281  INFO 3886 --- [           main] c.h.s.i.o.impl.OperationExecutorImpl     : [127.0.0.1]:15703 [dev] [3.9.1] Starting 2 partition threads and 3 generic threads (1 dedicated for priority tasks)
2018-03-16 20:53:18.286  INFO 3886 --- [           main] c.h.internal.diagnostics.Diagnostics     : [127.0.0.1]:15703 [dev] [3.9.1] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
2018-03-16 20:53:18.297  INFO 3886 --- [           main] com.hazelcast.core.LifecycleService      : [127.0.0.1]:15703 [dev] [3.9.1] [127.0.0.1]:15703 is STARTING
2018-03-16 20:53:18.337  INFO 3886 --- [           main] com.hazelcast.system                     : [127.0.0.1]:15703 [dev] [3.9.1] Cluster version set to 3.9
2018-03-16 20:53:18.338  INFO 3886 --- [           main] c.h.internal.cluster.ClusterService      : [127.0.0.1]:15703 [dev] [3.9.1] 

Members {size:1, ver:1} [
    Member [127.0.0.1]:15703 - bac85484-097d-464e-bbd7-ec3bc19904ef this
]

2018-03-16 20:53:18.409  INFO 3886 --- [           main] com.hazelcast.core.LifecycleService      : [127.0.0.1]:15703 [dev] [3.9.1] [127.0.0.1]:15703 is STARTED
2018-03-16 20:53:19.291  INFO 3886 --- [           main] o.l.s.dispatcher.config.WebConfigurer    : Web application configuration, using profiles: swagger
2018-03-16 20:53:19.292 DEBUG 3886 --- [           main] o.l.s.dispatcher.config.WebConfigurer    : Initializing Metrics registries
2018-03-16 20:53:19.297 DEBUG 3886 --- [           main] o.l.s.dispatcher.config.WebConfigurer    : Registering Metrics Filter
2018-03-16 20:53:19.297 DEBUG 3886 --- [           main] o.l.s.dispatcher.config.WebConfigurer    : Registering Metrics Servlet
2018-03-16 20:53:19.300 DEBUG 3886 --- [           main] o.l.s.dispatcher.config.WebConfigurer    : Initialize H2 console
2018-03-16 20:53:19.301  INFO 3886 --- [           main] o.l.s.dispatcher.config.WebConfigurer    : Web application fully configured
2018-03-16 20:53:20.272 DEBUG 3886 --- [           main] o.l.s.d.config.DatabaseConfiguration     : Configuring Liquibase
2018-03-16 20:53:20.297  WARN 3886 --- [cher-Executor-1] i.g.j.c.liquibase.AsyncSpringLiquibase   : Starting Liquibase asynchronously, your database might not be ready at startup!
2018-03-16 20:53:20.431  INFO 3886 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_DISPATCHER/dispatcher:4b01cdcf216b23bd82b25f5a376f7f44 - Re-registering apps/DISPATCHER
2018-03-16 20:53:20.431  INFO 3886 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_DISPATCHER/dispatcher:4b01cdcf216b23bd82b25f5a376f7f44: registering service...
2018-03-16 20:53:20.542  INFO 3886 --- [tbeatExecutor-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_DISPATCHER/dispatcher:4b01cdcf216b23bd82b25f5a376f7f44 - registration status: 204
2018-03-16 20:53:22.671 DEBUG 3886 --- [cher-Executor-1] i.g.j.c.liquibase.AsyncSpringLiquibase   : Liquibase has updated your database in 2373 ms
2018-03-16 20:53:23.278  INFO 3886 --- [           main] c.h.h.HazelcastCacheRegionFactory        : Starting up HazelcastCacheRegionFactory
2018-03-16 20:53:23.282  INFO 3886 --- [           main] c.h.h.i.IHazelcastInstanceFactory        : Using existing HazelcastInstance [dispatcher].
2018-03-16 20:53:28.252 DEBUG 3886 --- [           main] o.l.s.d.config.CacheConfiguration        : Starting HazelcastCacheManager
2018-03-16 20:53:29.720  WARN 3886 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2018-03-16 20:53:30.294 DEBUG 3886 --- [           main] .l.s.d.c.o.OAuth2JwtAccessTokenConverter : Public key retrieved from OAuth2 server to create SignatureVerifier
2018-03-16 20:53:30.417  WARN 3886 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodSecurityInterceptor' defined in class path resource [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: An AuthenticationManager is required
2018-03-16 20:53:30.438  INFO 3886 --- [           main] c.h.h.HazelcastCacheRegionFactory        : Shutting down HazelcastCacheRegionFactory
2018-03-16 20:53:30.439  WARN 3886 --- [           main] c.h.h.i.IHazelcastInstanceFactory        : hibernate.cache.hazelcast.shutdown_on_session_factory_close property is set to 'false'. Leaving current HazelcastInstance active! (Warning: Do not disable Hazelcast hazelcast.shutdownhook.enabled property!)
2018-03-16 20:53:30.439  INFO 3886 --- [           main] com.hazelcast.core.LifecycleService      : [127.0.0.1]:15703 [dev] [3.9.1] [127.0.0.1]:15703 is SHUTTING_DOWN
2018-03-16 20:53:30.444  INFO 3886 --- [           main] com.hazelcast.instance.Node              : [127.0.0.1]:15703 [dev] [3.9.1] Shutting down connection manager...
2018-03-16 20:53:30.447  INFO 3886 --- [           main] com.hazelcast.instance.Node              : [127.0.0.1]:15703 [dev] [3.9.1] Shutting down node engine...
2018-03-16 20:53:30.460  INFO 3886 --- [           main] com.hazelcast.instance.NodeExtension     : [127.0.0.1]:15703 [dev] [3.9.1] Destroying node NodeExtension.
2018-03-16 20:53:30.460  INFO 3886 --- [           main] com.hazelcast.instance.Node              : [127.0.0.1]:15703 [dev] [3.9.1] Hazelcast Shutdown is completed in 16 ms.
2018-03-16 20:53:30.466  INFO 3886 --- [           main] com.hazelcast.core.LifecycleService      : [127.0.0.1]:15703 [dev] [3.9.1] [127.0.0.1]:15703 is SHUTDOWN
2018-03-16 20:53:30.466  INFO 3886 --- [           main] o.l.s.d.config.CacheConfiguration        : Closing Cache Manager
2018-03-16 20:53:30.491  INFO 3886 --- [           main] com.netflix.discovery.DiscoveryClient    : Shutting down DiscoveryClient ...
2018-03-16 20:53:30.498  WARN 3886 --- [           main] .s.c.a.CommonAnnotationBeanPostProcessor : Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaInstanceConfigBean': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
2018-03-16 20:53:30.528 ERROR 3886 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'methodSecurityInterceptor' defined in class path resource [org/springframework/security/config/annotation/method/configuration/GlobalMethodSecurityConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: An AuthenticationManager is required
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at org.lightyourlamp.services.dispatcher.DispatcherApp.main(DispatcherApp.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
    at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59)
Caused by: java.lang.IllegalArgumentException: An AuthenticationManager is required
    at org.springframework.util.Assert.notNull(Assert.java:134)
    at org.springframework.security.access.intercept.AbstractSecurityInterceptor.afterPropertiesSet(AbstractSecurityInterceptor.java:121)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
    ... 22 common frames omitted
4

0 回答 0