wanlion

wanlion 查看完整档案

填写现居城市  |  填写毕业院校  |  填写所在公司/组织填写个人主网站
编辑

万里云

个人动态

wanlion 提出了问题 · 9月19日

java spring security SSO 登录, 客户端启动报错

折腾了一两周了, 问题始终没有解决, 只能来这里求助了, 希望知道的朋友帮忙下!
下面开始说需求:
公司有两个系统, 我们就称之为聊天系统和业务系统吧, 聊天系统是因为业务系统需要沟通才存在, 聊天系统本身是没有用户, 用户都是来自业务系统.

这两个系统都需要保存数据到数据库, 因为聊天系统需要保存聊天记录, 业务系统也有业务数据需要保存, 两个系统用的框架都是spring boot,而且都是使用 mybatis, 当然了, 出于安全的需要, 就用到了 spring security, 本来是想成立一个用户中心, 但是公司除了这两个系统外,还有其他系统, 这样牵连比较大, 所以没有成立用户中心, 但聊天系统和业务系统本身是需要数据交互的.

所以, 引入 spring security 了以后, 我就想到 SSO 单点登录, 网上了解了下, spring security 实现单点登录的方式还有好多种方式的, 比如用到 CAS, JWT 等等, 我就选择使用 @EnableOAuth2Sso 注解这个方式来实现单点登录, 但是我折腾了好久, 问题始终没有解决.

出现的问题是:
聊天系统(客户端)启动时, 会自动向业务系统(授权端)发起一个 get 请求: oauth/token_key,
业务系统也能收到这个 get 请求, 但它却重定向去获取 static/index.html, 这是业务系统的首页, 但由于前后端分离, 前端采用 vue 来开发, 所以不存在这个页面, 报 404 错误!

请注意: 这个 get 请求的地址在聊天系统(客户端)的 application.properties 文件中配置, key 为: security.oauth2.resource.jwt.key-uri

我产生的疑问是:
1) 聊天系统发起这个 get 请求的时候, 不应该去获取 index.html, 我也不知道发起这个 get 请求的目的是什么, 但他不应该去登录或者请求首页.
2) 网上看到文章, 聊天系统作为客户端, 使用 @EnableOAuth2Sso 来实现单点登录的时候, 聊天系统是不需要配置 security.oauth2.resource.jwt.key-uri 的, 但是我不配置就报错.报错如下:

Description:

Method springSecurityFilterChain in 
org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration 
required a bean of type 'org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory' that could not be found.

The following candidates were found but could not be injected:
    - Bean method 'userInfoRestTemplateFactory' in 'ResourceServerTokenServicesConfiguration' not loaded because @ConditionalOnMissingBean (types: org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration; SearchStrategy: all) found beans of type 'org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration' org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.boot.autoconfigure.security.oauth2.resource.UserInfoRestTemplateFactory' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:9125', transport: 'socket'

Process finished with exit code 1

下面给出聊天系统(客户端) spring security 的安全配置:

@Configuration
//@EnableWebSecurity()
@EnableOAuth2Sso
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Resource
 private DataSource dataSource;
 @Bean
 @Override protected UserDetailsService userDetailsService() {
        JdbcUserDetailsManager manager = getUserDetailsService();
 manager.setDataSource(dataSource);
 return manager;
 }
    public static JdbcUserDetailsManager getUserDetailsService() {
        JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
 manager.setUsersByUsernameQuery("select login_name AS username, password,'1' AS enabled  from im_user where login_name=?");
 manager.setAuthoritiesByUsernameQuery("select login_name AS username, 'user' AS authority   from im_user where login_name=?");
 return manager;
 }
    @Bean
 PasswordEncoder passwordEncoder() {
        return PasswordEncoderFactories.createDelegatingPasswordEncoder();
 }
    /**
 * 这一步的配置是必不可少的,否则SpringBoot会自动配置一个 AuthenticationManager,覆盖掉内存中的用户
 */
 @Bean
 @Override public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
 }
    @Override
 protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().authenticated().and().csrf().disable();
 }
}

业务系统(资源/授权)服务器的 spring security 安全配置如下:

@Order(1)
@Configuration
@EnableWebSecurity(debug=true)
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
    @Autowired
 SysUserDetailService userDetailService;
 // 上传图片所在的路径
 @Value("${UPLOAD_STATIC_PATH}")
    private String UPLOAD_STATIC_PATH;
 @Override
 protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailService)
            .passwordEncoder(passwordEncoder());
 }
    @Bean
 PasswordEncoder passwordEncoder() {
        return PasswordEncoderFactories.createDelegatingPasswordEncoder();
 }
    /**
 * 这一步的配置是必不可少的,否则SpringBoot会自动配置一个 AuthenticationManager,覆盖掉内存中的用户
 */
 @Bean
 @Override public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
 }
    @Override
 public void configure(WebSecurity web) throws Exception {
        String[] ignoreList = {
            UPLOAD_STATIC_PATH, "static/index.html", "favicon.ico", "/static/**"
 };
 web.ignoring().antMatchers(ignoreList);
 }
    @Override
 protected void configure(HttpSecurity http) throws Exception {
        String[] permits = {"/oauth/**", "/oauths/**", "/lgn"};
 http.authorizeRequests()
                .antMatchers(permits).permitAll()
            .and()
                .formLogin()
                .loginPage("/lgn")
                .loginProcessingUrl("/user/lgn")
                .successHandler((request, response, authentication) -> {
                    RequestDispatcher dispatcher = request.getRequestDispatcher("/user/loginSuccess");
 dispatcher.forward(request, response);
 })
                .failureHandler((request, response, authentication) -> {
                    RequestDispatcher dispatcher = request.getRequestDispatcher("/user/loginError");
 dispatcher.forward(request, response);
 })
                .permitAll()
            .and()
                .authorizeRequests().anyRequest().authenticated()
            .and()
                .csrf()
                .disable();
 http.logout()
            .logoutUrl("/user/exit")
            .logoutSuccessHandler(
                new LogoutSuccessHandler() {
                    @Override
 public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
                        RequestDispatcher dispatcher = request.getRequestDispatcher("/user/exitSuccess");
 dispatcher.forward(request, response);
 }
            });
 }
}

下面给出业务系统的授权及资源配置:

@Configuration
 @EnableAuthorizationServer()
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
   @Resource
 AuthenticationManager authenticationManager;
 @Resource
 private UserDetailsService userDetailsService;
 public final static String clientId = "aaa";
 public final  static String scopes = "select";
 public final  static String rawPassword = "bbb";
 @Override
 public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
      String finalSecret = "{bcrypt}" + new BCryptPasswordEncoder().encode(rawPassword);
 clients.inMemory().withClient(clientId)
            .authorizedGrantTypes("password", "refresh_token", "authorization_code")
            .autoApprove(true)
            .scopes(scopes, "user")
            .authorities("oauth2")
            .secret(finalSecret)
            .accessTokenValiditySeconds(7200)
      ;
 }
   @Bean
 public TokenStore getTokenStore() {
      return new InMemoryTokenStore();
 }
   @Override
 public void configure(AuthorizationServerEndpointsConfigurer endpoints) {
      endpoints.authenticationManager(authenticationManager)
            .tokenStore(getTokenStore())
                .userDetailsService(userDetailsService)
                .allowedTokenEndpointRequestMethods(HttpMethod.GET, HttpMethod.POST)
              ;
 endpoints.tokenServices(tokenServices());
 }
   @Override
 public void configure(AuthorizationServerSecurityConfigurer oauthServer) {
//    oauthServer.allowFormAuthenticationForClients();
 oauthServer.allowFormAuthenticationForClients()
            .tokenKeyAccess("permitAll()")
            .checkTokenAccess("isAuthenticated()");
 }
   @Bean
 public DefaultTokenServices tokenServices() {
      final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
 defaultTokenServices.setTokenStore(getTokenStore());
 return defaultTokenServices;
 }
   @Configuration
 @EnableResourceServer 
 protected static class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
      @Override
 public void configure(ResourceServerSecurityConfigurer resources) {}
      @Override
 public void configure(HttpSecurity http) throws Exception {
          String[] permits = {"/oauth/**", "/oauths/**", "/user/lgn"};
 http
            .authorizeRequests()
               .antMatchers("/api/**")
               .authenticated().and()
               .authorizeRequests().antMatchers(permits).permitAll().and()
            .cors().and()
            .rememberMe().and()
            .csrf().disable();
 }
   }
}

另外还有一点@EnableResourceServer 注解已经加在业务系统(授权/资源端)的 spring boot 启动类.

聊天系统(客户端)启动报错如下:

java.lang.Object.wait(Native Method)
 java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
 com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
2020-09-19 11:37:21.673 ERROR 10832 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'startTioRunner': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tioWsMsgHandler': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtTokenServices' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Unsatisfied dependency expressed through method 'jwtTokenServices' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenStore' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'jwtTokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:846)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:863)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
    at com.VServerApplication.main(VServerApplication.java:24)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'startTioRunner': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tioWsMsgHandler': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtTokenServices' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Unsatisfied dependency expressed through method 'jwtTokenServices' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenStore' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'jwtTokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:525)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:630)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:321)
    ... 17 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tioWsMsgHandler': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtTokenServices' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Unsatisfied dependency expressed through method 'jwtTokenServices' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenStore' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'jwtTokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:324)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:525)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:630)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:321)
    ... 30 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtTokenServices' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Unsatisfied dependency expressed through method 'jwtTokenServices' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenStore' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'jwtTokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1244)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:518)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:630)
    at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:180)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:321)
    ... 43 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenStore' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'jwtTokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1244)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
    ... 61 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'jwtTokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
    ... 75 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtTokenEnhancer' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1288)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1127)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:394)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:366)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration$$EnhancerBySpringCGLIB$$3a097132.jwtTokenEnhancer(<generated>)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.jwtTokenStore(ResourceServerTokenServicesConfiguration.java:267)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration$$EnhancerBySpringCGLIB$$3a097132.CGLIB$jwtTokenStore$2(<generated>)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration$$EnhancerBySpringCGLIB$$3a097132$$FastClassBySpringCGLIB$$f723e408.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration$$EnhancerBySpringCGLIB$$3a097132.jwtTokenStore(<generated>)
    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.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 76 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtTokenEnhancer' threw exception; nested exception is org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)
    ... 99 common frames omitted
Caused by: org.springframework.web.client.HttpClientErrorException$NotFound: 404 null
    at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:85)
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:122)
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:102)
    at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
    at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:777)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:735)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:578)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.getKeyFromServer(ResourceServerTokenServicesConfiguration.java:310)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration.jwtTokenEnhancer(ResourceServerTokenServicesConfiguration.java:275)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration$$EnhancerBySpringCGLIB$$3a097132.CGLIB$jwtTokenEnhancer$0(<generated>)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration$$EnhancerBySpringCGLIB$$3a097132$$FastClassBySpringCGLIB$$f723e408.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363)
    at org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerTokenServicesConfiguration$JwtTokenServicesConfiguration$$EnhancerBySpringCGLIB$$3a097132.jwtTokenEnhancer(<generated>)
    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.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 100 common frames omitted

Disconnected from the target VM, address: '127.0.0.1:9209', transport: 'socket'

Process finished with exit code 1

业务系统收到 get 请求, 报错如下:

2020-09-19 11:37:21.236 DEBUG 13408 --- [nio-8090-exec-1] o.a.coyote.http11.Http11InputBuffer      : Received [GET /oauth/token_key HTTP/1.1
Accept: application/json, application/*+json
Authorization: Basic eGhJbTp4aC1pbS1zeXM=
User-Agent: Java/1.8.0_101
Host: localhost:8090
Connection: keep-alive

]
2020-09-19 11:37:21.267 DEBUG 13408 --- [nio-8090-exec-1] org.apache.tomcat.util.http.Parameters   : Set query string encoding to UTF-8
2020-09-19 11:37:21.267 DEBUG 13408 --- [nio-8090-exec-1] o.a.c.authenticator.AuthenticatorBase    : Security checking request GET /oauth/token_key
2020-09-19 11:37:21.267 DEBUG 13408 --- [nio-8090-exec-1] org.apache.catalina.realm.RealmBase      :   No applicable constraints defined
2020-09-19 11:37:21.283 DEBUG 13408 --- [nio-8090-exec-1] o.a.c.a.jaspic.AuthConfigFactoryImpl     : Loading persistent provider registrations from [C:\Users\weizhijin\AppData\Local\Temp\tomcat.1718251064941918955.8090\conf\jaspic-providers.xml]
2020-09-19 11:37:21.283 DEBUG 13408 --- [nio-8090-exec-1] o.a.c.authenticator.AuthenticatorBase    : Not subject to any constraint
2020-09-19 11:37:21.283  INFO 13408 --- [nio-8090-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-09-19 11:37:21.283  INFO 13408 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-09-19 11:37:21.283 DEBUG 13408 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Detected StandardServletMultipartResolver
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
2020-09-19 11:37:21.298  INFO 13408 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 15 ms
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/upload/**'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against 'static/index.html'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against 'favicon.ico'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/static/**'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/fabu'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/tongcheng'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/edit'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/xiuchang'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/ruzhu'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/login'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/paotui'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/index'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/todayMsg/list'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/post/list'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/busn/list/*'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/file/temp'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/nearby'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/getInfo'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/sign'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/dvrysign'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/mersign'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/category/list/*'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/oauth/token']
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/oauth/token'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/oauth/token_key']
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/oauth/token_key'
2020-09-19 11:37:21.298 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : matched
2020-09-19 11:37:21.298  INFO 13408 --- [nio-8090-exec-1] Spring Security Debugger                 : 

************************************************************

Request received for GET '/oauth/token_key':

org.apache.catalina.connector.RequestFacade@6c7a85e1

servletPath:/oauth/token_key
pathInfo:null
headers: 
accept: application/json, application/*+json
authorization: Basic eGhJbTp4aC1pbS1zeXM=
user-agent: Java/1.8.0_101
host: localhost:8090
connection: keep-alive


Security filter chain: [
  WebAsyncManagerIntegrationFilter
  SecurityContextPersistenceFilter
  HeaderWriterFilter
  LogoutFilter
  ClientCredentialsTokenEndpointFilter
  BasicAuthenticationFilter
  RequestCacheAwareFilter
  SecurityContextHolderAwareRequestFilter
  AnonymousAuthenticationFilter
  SessionManagementFilter
  ExceptionTranslationFilter
  FilterSecurityInterceptor
]


************************************************************


2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/upload/**'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against 'static/index.html'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against 'favicon.ico'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/static/**'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/fabu'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/tongcheng'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/edit'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/xiuchang'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/ruzhu'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/login'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/paotui'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/index'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/todayMsg/list'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/post/list'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/busn/list/*'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/file/temp'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/nearby'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/getInfo'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/sign'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/dvrysign'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/user/mersign'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/category/list/*'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/oauth/token']
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/oauth/token'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/oauth/token_key']
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/oauth/token_key'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : matched
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 1 of 12 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 2 of 12 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 3 of 12 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 4 of 12 in additional filter chain; firing Filter: 'LogoutFilter'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', GET]
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/logout'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', POST]
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /oauth/token_key' doesn't match 'POST /logout'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', PUT]
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /oauth/token_key' doesn't match 'PUT /logout'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', DELETE]
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /oauth/token_key' doesn't match 'DELETE /logout'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 5 of 12 in additional filter chain; firing Filter: 'ClientCredentialsTokenEndpointFilter'
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] org.apache.tomcat.util.http.Parameters   : Set encoding to UTF-8
2020-09-19 11:37:21.314 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 6 of 12 in additional filter chain; firing Filter: 'BasicAuthenticationFilter'
2020-09-19 11:37:21.330 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.a.www.BasicAuthenticationFilter  : Basic Authentication Authorization header found for user 'xhIm'
2020-09-19 11:37:21.330 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.authentication.ProviderManager     : Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider
2020-09-19 11:37:21.423 DEBUG 13408 --- [nio-8090-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating shared instance of singleton bean 'scopedTarget.clientDetailsService'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.a.www.BasicAuthenticationFilter  : Authentication success: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@3d30b2f5: Principal: org.springframework.security.core.userdetails.User@381c34: Username: xhIm; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: oauth2; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: oauth2
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 7 of 12 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.s.HttpSessionRequestCache        : saved request doesn't match
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 8 of 12 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 9 of 12 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.a.AnonymousAuthenticationFilter  : SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@3d30b2f5: Principal: org.springframework.security.core.userdetails.User@381c34: Username: xhIm; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: oauth2; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: oauth2'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 10 of 12 in additional filter chain; firing Filter: 'SessionManagementFilter'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] s.CompositeSessionAuthenticationStrategy : Delegating to org.springframework.security.web.authentication.session.ChangeSessionIdAuthenticationStrategy@5e1a986c
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 11 of 12 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key at position 12 of 12 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/oauth/token'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/oauth/token_key'; against '/oauth/token_key'
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.a.i.FilterSecurityInterceptor    : Secure object: FilterInvocation: URL: /oauth/token_key; Attributes: [permitAll()]
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.a.i.FilterSecurityInterceptor    : Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@3d30b2f5: Principal: org.springframework.security.core.userdetails.User@381c34: Username: xhIm; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: oauth2; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null; Granted Authorities: oauth2
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.access.vote.AffirmativeBased       : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@1b0b08f9, returned: 1
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.a.i.FilterSecurityInterceptor    : Authorization successful
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.a.i.FilterSecurityInterceptor    : RunAsManager did not change Authentication object
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.security.web.FilterChainProxy        : /oauth/token_key reached end of additional filter chain; proceeding with original chain
2020-09-19 11:37:21.533 DEBUG 13408 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : GET "/oauth/token_key", parameters={}
2020-09-19 11:37:21.548 DEBUG 13408 --- [nio-8090-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2020-09-19 11:37:21.548 DEBUG 13408 --- [nio-8090-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Resource not found
2020-09-19 11:37:21.548 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@6daa06c4
2020-09-19 11:37:21.548 DEBUG 13408 --- [nio-8090-exec-1] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND
2020-09-19 11:37:21.548 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.a.ExceptionTranslationFilter     : Chain processed normally
2020-09-19 11:37:21.548 DEBUG 13408 --- [nio-8090-exec-1] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2020-09-19 11:37:21.548 DEBUG 13408 --- [nio-8090-exec-1] o.a.c.c.C.[Tomcat].[localhost]           : Processing ErrorPage[errorCode=404, location=/static/index.html]
2020-09-19 11:37:21.564 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/static/index.html'; against '/upload/**'
2020-09-19 11:37:21.564 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/static/index.html'; against 'static/index.html'
2020-09-19 11:37:21.564 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/static/index.html'; against 'favicon.ico'
2020-09-19 11:37:21.564 DEBUG 13408 --- [nio-8090-exec-1] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/static/index.html'; against '/static/**'
2020-09-19 11:37:21.564  INFO 13408 --- [nio-8090-exec-1] Spring Security Debugger                 : 

************************************************************

Request received for GET '/static/index.html':

org.apache.catalina.core.ApplicationHttpRequest@2984d4b5

servletPath:/static/index.html
pathInfo:null
headers: 
accept: application/json, application/*+json
authorization: Basic eGhJbTp4aC1pbS1zeXM=
user-agent: Java/1.8.0_101
host: localhost:8090
connection: keep-alive


Security filter chain: [] empty (bypassed by security='none') 


************************************************************


java.io.IOException: ?????????????????
    at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[na:1.8.0_101]
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[na:1.8.0_101]
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.8.0_101]
    at sun.nio.ch.IOUtil.read(IOUtil.java:197) ~[na:1.8.0_101]
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380) ~[na:1.8.0_101]
    at org.apache.tomcat.util.net.NioChannel.read(NioChannel.java:163) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1228) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1140) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:780) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:356) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:260) ~[tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589) [tomcat-embed-core-9.0.37.jar:9.0.37]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.37.jar:9.0.37]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_101]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_101]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.37.jar:9.0.37]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_101]

最后的问题:
我的配置有什么问题吗? 或者我应该怎么样做才能够实现单点登录?

关注 2 回答 1

wanlion 提出了问题 · 2018-11-27

多个公众号都连接到同一个域名, 还是每个公众号各自配一个域名来连接?

公司有一个公众号, 这个公众号指向一个系统, 我们就把这个系统称之为系统A吧.
但是系统A仅仅是一个客户端系统, 它不处理任何的数据, 当然也不会保存任何的数据, 数据的存储和处理都由另外一个后台系统来处理, 这个后台系统我们称之为系统B吧, 这样, 用户使用公众号的完整请求过程应该是这样:
微信 --> 微信服务器 --> 系统A --> 系统B

由于业务的发展, 同行的其他公司也希望拥有一个公众号, 但业务的数据保存在我们的服务器.
于是, 我初步的打算是, 给他们开通一个新的公众号, 配置一个新的子域名, 然后把系统A做一个拷贝, 部署成系统C, 部署完成后, 两个公众号同时运行, 于是, 请求过程应该是下面这样子:

原公众号: 微信 --> 微信服务器 --> 系统A --> 系统B
新公众号: 微信 --> 微信服务器 --> 系统C --> 系统B

但是老板持不同的意见, 认为没必要去配置新的域名, 部署新的系统, 两个公众号同时指向系统A就可以了, 按照他的想法, 两个公众号的请求过程应该是下面这样子:

原公众号: 微信 --> 微信服务器 --> 系统A --> 系统B
新公众号: 微信 --> 微信服务器 --> 系统A --> 系统B

那么, 如何区分用户是属于哪个公众号的呢?
我觉得可行的办法是, 当微信服务器向系统A发起请求的时候, 在URL地址中加入一个请求参数, 用来标识是哪个系统的用户, 然后, 系统 A 把这个标识写入到 session 中, 这样的话, 系统 A 向系统 B 发起请求的时候, 再把标识传过去, 系统 B 也能够识别是哪个公众号的用户.

但还有另外一个问题, 那就是, 微信服务器和系统A交互的时候, 是需要 AppID 和 AppSecret 的, 这就意味着, 我得额外去修改代码才能达到老板的要求, 这是我不情愿的.
但是, 老板不希望每增加一个公众号就要配置一个子域名, 部署一个应用, 这是老板不希望的.

我的问题是:
1) 哪个方案好? 我应该听从老板的建议还是坚持自己的意见? 或者, 还有更好的解决方案? 这是重点.
2) 多个公众号同时连接到同一个系统, 使用的是同一个域名, 不知道微信有没有做限制?

哪位高手帮忙解答下, 重要的是问题 1, 多谢了!

关注 2 回答 1

wanlion 回答了问题 · 2018-11-27

解决企业微信开发, 如何发送消息给外部联系人?

在微信群里面问过其他人, 如果这个问题能够解决的话, 肯定有人写爬虫来推送消息, 这是微信所不愿意的

关注 9 回答 6

wanlion 关注了专栏 · 2018-11-27

后端系列进阶

主要用于记录在后端开发方面的一些经验、踩过的坑以及思考

关注 285

wanlion 关注了用户 · 2018-11-27

前端大彬哥 @dabinge666

10以上年编程经验,曾主持并参与多个公司大型项目的开发,在教育机构主导前端课程研发工作,输送大批学生进入国内一线互联网公司。

关注 1117

wanlion 关注了专栏 · 2018-11-27

Gauch

Gauch的人生足迹

关注 444

wanlion 关注了专栏 · 2018-11-27

终身学习者

我要先坚持分享20年,大家来一起见证吧。

关注 40889

wanlion 关注了标签 · 2018-11-27

javascript

JavaScript 是一门弱类型的动态脚本语言,支持多种编程范式,包括面向对象和函数式编程,被广泛用于 Web 开发。

一般来说,完整的JavaScript包括以下几个部分:

  • ECMAScript,描述了该语言的语法和基本对象
  • 文档对象模型(DOM),描述处理网页内容的方法和接口
  • 浏览器对象模型(BOM),描述与浏览器进行交互的方法和接口

它的基本特点如下:

  • 是一种解释性脚本语言(代码不进行预编译)。
  • 主要用来向HTML页面添加交互行为。
  • 可以直接嵌入HTML页面,但写成单独的js文件有利于结构和行为的分离。

JavaScript常用来完成以下任务:

  • 嵌入动态文本于HTML页面
  • 对浏览器事件作出响应
  • 读写HTML元素
  • 在数据被提交到服务器之前验证数据
  • 检测访客的浏览器信息

《 Javascript 优点在整个语言中占多大比例?

关注 135156

wanlion 关注了标签 · 2018-11-27

java

Java 是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由 Sun Microsystems 公司于 1995 年 5 月推出的 Java 程序设计语言和 Java 平台(即 JavaSE, JavaEE, JavaME)的总称。Java 技术具有卓越的通用性、高效性、平台移植性和安全性。

Java编程语言的风格十分接近 C++ 语言。继承了 C++ 语言面向对象技术的核心,Java舍弃了 C++ 语言中容易引起错误的指針,改以引用取代,同时卸载原 C++ 与原来运算符重载,也卸载多重继承特性,改用接口取代,增加垃圾回收器功能。在 Java SE 1.5 版本中引入了泛型编程、类型安全的枚举、不定长参数和自动装/拆箱特性。太阳微系统对 Java 语言的解释是:“Java编程语言是个简单、面向对象、分布式、解释性、健壮、安全与系统无关、可移植、高性能、多线程和动态的语言”。

版本历史

重要版本号版本代号发布日期
JDK 1.01996 年 1 月 23 日
JDK 1.11997 年 2 月 19 日
J2SE 1.2Playground1998 年 12 月 8 日
J2SE 1.3Kestrel2000 年 5 月 8 日
J2SE 1.4Merlin2002 年 2 月 6 日
J2SE 5.0 (1.5.0)Tiger2004 年 9 月 30 日
Java SE 6Mustang2006 年 11 月 11 日
Java SE 7Dolphin2011 年 7 月 28 日
Java SE 8JSR 3372014 年 3 月 18 日
最新发布的稳定版本:
Java Standard Edition 8 Update 11 (1.8.0_11) - (July 15, 2014)
Java Standard Edition 7 Update 65 (1.7.0_65) - (July 15, 2014)

更详细的版本更新查看 J2SE Code NamesJava version history 维基页面

新手帮助

不知道如何开始写你的第一个 Java 程序?查看 Oracle 的 Java 上手文档

在你遇到问题提问之前,可以先在站内搜索一下关键词,看是否已经存在你想提问的内容。

命名规范

Java 程序应遵循以下的 命名规则,以增加可读性,同时降低偶然误差的概率。遵循这些命名规范,可以让别人更容易理解你的代码。

  • 类型名(类,接口,枚举等)应以大写字母开始,同时大写化后续每个单词的首字母。例如:StringThreadLocaland NullPointerException。这就是著名的帕斯卡命名法。
  • 方法名 应该是驼峰式,即以小写字母开头,同时大写化后续每个单词的首字母。例如:indexOfprintStackTraceinterrupt
  • 字段名 同样是驼峰式,和方法名一样。
  • 常量表达式的名称static final 不可变对象)应该全大写,同时用下划线分隔每个单词。例如:YELLOWDO_NOTHING_ON_CLOSE。这个规范也适用于一个枚举类的值。然而,static final 引用的非不可变对象应该是驼峰式。

Hello World

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

编译并调用:

javac -d . HelloWorld.java
java -cp . HelloWorld

Java 的源代码会被编译成可被 Java 命令执行的中间形式(用于 Java 虚拟机的字节代码指令)。

可用的 IDE

学习资源

常见的问题

下面是一些 SegmentFault 上在 Java 方面经常被人问到的问题:

(待补充)

关注 105554

wanlion 关注了标签 · 2018-11-27

css

层叠样式表(英语:Cascading Style Sheets,简写CSS),又称串样式列表,由W3C定义和维护的标准,一种用来为结构化文档(如HTML文档或XML应用)添加样式(字体、间距和颜色等)的计算机语言。

关注 61532

认证与成就

  • 获得 2 次点赞
  • 获得 53 枚徽章 获得 1 枚金徽章, 获得 20 枚银徽章, 获得 32 枚铜徽章

擅长技能
编辑

(゚∀゚ )
暂时没有

开源项目 & 著作
编辑

(゚∀゚ )
暂时没有

注册于 2014-10-26
个人主页被 711 人浏览