会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132600个问题
微服务/第一阶段:SSM 框架和项目开发/(旧)SpringMVC 27213楼
JAVA 全系列/预科阶段:职业规划/学习方法/JAVA 技术体系介绍和学习方法 27214楼

老师我觉得我这个项目写崩了有点。。。后台管理系统突然登录不进去了,,我这边没改什么东西啊。。下面试AdminServiceApplication报的异常信息



2020-12-07 02:15:24.452  INFO 3563 --- [nio-8080-exec-1] c.b.service.impl.SysLoginServiceImpl     : 用户admin开始登录

2020-12-07 02:15:24.610  INFO 3563 --- [nio-8080-exec-1] c.netflix.config.ChainedDynamicProperty  : Flipping property: authorization-server.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647

2020-12-07 02:15:24.623  INFO 3563 --- [nio-8080-exec-1] c.netflix.loadbalancer.BaseLoadBalancer  : Client: authorization-server instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=authorization-server,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null

2020-12-07 02:15:24.628  INFO 3563 --- [nio-8080-exec-1] c.n.l.DynamicServerListLoadBalancer      : Using serverListUpdater PollingServerListUpdater

2020-12-07 02:15:24.680  INFO 3563 --- [nio-8080-exec-1] com.alibaba.nacos.client.naming          : new ips(1) service: DEFAULT_GROUP@@authorization-server -> [{"clusterName":"DEFAULT","enabled":true,"ephemeral":true,"healthy":true,"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"instanceId":"192.168.86.147#9999#DEFAULT#DEFAULT_GROUP@@authorization-server","ip":"192.168.86.147","ipDeleteTimeout":30000,"metadata":{"preserved.register.source":"SPRING_CLOUD"},"port":9999,"serviceName":"DEFAULT_GROUP@@authorization-server","weight":1.0}]

2020-12-07 02:15:24.685  INFO 3563 --- [nio-8080-exec-1] com.alibaba.nacos.client.naming          : current ips:(1) service: DEFAULT_GROUP@@authorization-server -> [{"clusterName":"DEFAULT","enabled":true,"ephemeral":true,"healthy":true,"instanceHeartBeatInterval":5000,"instanceHeartBeatTimeOut":15000,"instanceId":"192.168.86.147#9999#DEFAULT#DEFAULT_GROUP@@authorization-server","ip":"192.168.86.147","ipDeleteTimeout":30000,"metadata":{"preserved.register.source":"SPRING_CLOUD"},"port":9999,"serviceName":"DEFAULT_GROUP@@authorization-server","weight":1.0}]

2020-12-07 02:15:24.694  INFO 3563 --- [nio-8080-exec-1] c.netflix.config.ChainedDynamicProperty  : Flipping property: authorization-server.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647

2020-12-07 02:15:24.696  INFO 3563 --- [nio-8080-exec-1] c.n.l.DynamicServerListLoadBalancer      : DynamicServerListLoadBalancer for client authorization-server initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=authorization-server,current list of Servers=[192.168.86.147:9999],Load balancer stats=Zone stats: {unknown=[Zone:unknown; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]

},Server stats: [[Server:192.168.86.147:9999; Zone:UNKNOWN; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Wed Dec 31 16:00:00 PST 1969; First connection made: Wed Dec 31 16:00:00 PST 1969; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]

]}ServerList:com.alibaba.cloud.nacos.ribbon.NacosServerList@6c941ca1

2020-12-07 02:15:24.964 ERROR 3563 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.FeignException$BadRequest: [400] during [POST] to [http://authorization-server/oauth/token?grant_type=password&username=admin&password=123456&login_type=admin_type] [OAuth2FeignClient#getToken(String,String,String,String,String)]: [{"error":"invalid_grant","error_description":"Bad credentials"}]] with root cause


feign.FeignException$BadRequest: [400] during [POST] to [http://authorization-server/oauth/token?grant_type=password&username=admin&password=123456&login_type=admin_type] [OAuth2FeignClient#getToken(String,String,String,String,String)]: [{"error":"invalid_grant","error_description":"Bad credentials"}]

at feign.FeignException.clientErrorStatus(FeignException.java:195) ~[feign-core-10.7.4.jar:na]

at feign.FeignException.errorStatus(FeignException.java:177) ~[feign-core-10.7.4.jar:na]

at feign.FeignException.errorStatus(FeignException.java:169) ~[feign-core-10.7.4.jar:na]

at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:92) ~[feign-core-10.7.4.jar:na]

at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:156) ~[feign-core-10.7.4.jar:na]

at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:80) ~[feign-core-10.7.4.jar:na]

at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:100) ~[feign-core-10.7.4.jar:na]

at com.sun.proxy.$Proxy140.getToken(Unknown Source) ~[na:na]

at com.bjsxt.service.impl.SysLoginServiceImpl.login(SysLoginServiceImpl.java:51) ~[classes/:na]

at com.bjsxt.controller.SysLoginController.login(SysLoginController.java:39) ~[classes/:na]

at com.bjsxt.controller.SysLoginController$$FastClassBySpringCGLIB$$75a59cd6.invoke(<generated>) ~[classes/:na]

at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:100) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at com.bjsxt.aspect.WebLogAspect.recodeWebLog(WebLogAspect.java:58) ~[classes/:na]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_211]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_211]

at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_211]

at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) ~[spring-aop-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at com.bjsxt.controller.SysLoginController$$EnhancerBySpringCGLIB$$138d1ae8.login(<generated>) ~[classes/:na]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_211]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_211]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_211]

at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_211]

at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:879) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationProcessingFilter.doFilter(OAuth2AuthenticationProcessingFilter.java:176) ~[spring-security-oauth2-2.3.4.RELEASE.jar:na]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.3.2.RELEASE.jar:5.3.2.RELEASE]

at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) ~[spring-boot-actuator-2.3.0.RELEASE.jar:2.3.0.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.6.RELEASE.jar:5.2.6.RELEASE]

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) [tomcat-embed-core-9.0.35.jar:9.0.35]

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.35.jar:9.0.35]

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_211]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_211]

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.35.jar:9.0.35]

at java.lang.Thread.run(Thread.java:748) [na:1.8.0_211]


2020-12-07 02:15:25.634  INFO 3563 --- [erListUpdater-0] c.netflix.config.ChainedDynamicProperty  : Flipping property: authorization-server.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647


JAVA 全系列/(隐藏)第二十三阶段:数字货币交易所项目/服务中台_后台管理系统的开发 27215楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程和并发编程(旧) 27216楼

老师麻烦帮我解释下这里面的参数tank,它是一个实例对象吗,如果是的话它是在哪里被实例化的?image.png

import pygame,time,random
from pygame.sprite import Sprite

SCREEN_WIDTH=700
SCREEN_HEIGHT=500
BG_COLOR=pygame.Color(0,0,0)
TEXT_COLOR=pygame.Color(255,0,0)

#定义一个基类
class BaseItem(Sprite):
    def __init__(self, color, width, height):
        # Call the parent class (Sprite) constructor
        pygame.sprite.Sprite.__init__(self)

class MainGame():
    my_tank=None
    window=None
    # 储存敌方坦克的列表
    enemyTankList=[]
    # 定义敌方坦克数量
    enemyTankCount=5
    # 储存我方子弹的列表
    myBulletList=[]
    # 存储敌方子弹的列表
    enemyBulletList=[]
    # 存储爆炸效果的列表
    explodeList=[]  
    def __init__(self):
        pass
    #开始游戏
    def startGame(self):
        # 加载主窗口
        # 初始化窗口
        pygame.display.init()
        # 设置窗口大小及显示窗口
        MainGame.window=pygame.display.set_mode([SCREEN_WIDTH,SCREEN_HEIGHT])
        # 初始化我方坦克
        MainGame.my_tank=Tank(350,350)
        # 初始化敌方坦克,储存到列表中
        self.createEnemyTank()
        # 设置窗口标题
        pygame.display.set_caption('坦克大战')
        while True:
            time.sleep(0.02)
            # 给窗口设置填充色
            MainGame.window.fill(BG_COLOR)
            # 获取事件
            self.getEvent()
            # 绘制文字
            MainGame.window.blit(self.getTextSurface('敌方剩余数量:'.format(len(MainGame.enemyTankList))),(10,10))
            # 调用坦克显示的方法
            MainGame.my_tank.displayTank()   
            # 循环遍历敌方坦克,展示敌方坦克
            self.blitEnemyTank()
            # 循环遍历显示我方坦克的子弹
            self.blitMyBullet()
            # 循环遍历敌方坦克的子弹
            self.blitEnemyBullet()
            # 循环遍历爆炸列表,展示爆炸效果
            self.blitExplode()
            # 调用坦克移动的方法,如果开关开启,坦克才能移动
            if not MainGame.my_tank.stop: 
                MainGame.my_tank.move()
            pygame.display.update()
    
    # 循环遍历敌方坦克,显示敌方坦克
    def blitEnemyTank(self):
        for enemyTank in MainGame.enemyTankList:
            # 判断当前敌方坦克是否或者
            if enemyTank.live:
                enemyTank.displayTank()
                enemyTank.ranMove()
                # 发射子弹
                enemyBullet=enemyTank.shot()
                # 判断敌方子弹是否为None,如果不为None,则添加到列表中
                if enemyBullet:
                    # 将敌方子弹存储到列表中
                    MainGame.enemyBulletList.append(enemyBullet)
            else:
                # 从敌方坦克列表中删除
                MainGame.enemyTankList.remove(enemyTank)

    def createEnemyTank(self):
        top=100
        # 通过循环生成坦克
        for i in range(MainGame.enemyTankCount):
            left=random.randint(0,600)
            speed=random.randint(1,4)
            enemy=EnemyTank(left,top,speed)
            MainGame.enemyTankList.append(enemy) 

    # 循环遍历我方子弹,显示我方坦克的子弹
    def blitMyBullet(self):
        for myBullet in MainGame.myBulletList:
            # 判断子弹状态
            if myBullet.live:
                myBullet.displayBullet()
                myBullet.move() 
                # 检查子弹的状态
                myBullet.myBullet_hit_enemyTank()
            # 在列表中删除子弹
            else:
                MainGame.myBulletList.remove(myBullet)
            
    # 循环遍历敌方子弹,显示敌方坦克的子弹
    def blitEnemyBullet(self):
        for enemyBullet in MainGame.enemyBulletList:
            if enemyBullet.live:
                enemyBullet.displayBullet()
                enemyBullet.move()
            else:
                MainGame.enemyBulletList.remove(enemyBullet)
    
    # 循环遍历爆炸列表,展示爆炸效果
    def blitExplode(self):
        for explode in MainGame.explodeList:
            # 判断状态
            if explode.live:
                explode.displayExplode()
            else:
                # 从列表中移除
                MainGame.explodeList.remove(explode)

    #结束游戏
    def endGame(self):
        print('游戏结束,谢谢使用!!!')
        exit()

    def getTextSurface(self,text):
        # 初始化字体模块
        pygame.font.init()
        # # 查看所有字体的名称
        # print(pygame.font.get_fonts())
        # 获取字体font对象
        font=pygame.font.SysFont('kaiti',18)
        # 绘制文本信息
        textSurface=font.render(text,True,TEXT_COLOR)
        return textSurface

    # 获取事件
    def getEvent(self):
        # 获取所有文件
        eventList=pygame.event.get()
        # 遍历事件
        for event in eventList:
            # 判断按下的键
            # 如果按的是退出,则关闭窗口
            if event.type==pygame.QUIT:
                self.endGame()
            # 如果按下键盘
            if event.type==pygame.KEYDOWN:
                if event.key==pygame.K_LEFT:
                   # 切换方向
                   MainGame.my_tank.direction='L'
                   # 开启坦克开关
                   MainGame.my_tank.stop=False
        
                elif event.key==pygame.K_RIGHT:
                    # 切换方向
                   MainGame.my_tank.direction='R'# 开启坦克开关
                   MainGame.my_tank.stop=False
                
                elif event.key==pygame.K_UP:
                    # 切换方向
                   MainGame.my_tank.direction='U'# 开启坦克开关
                   MainGame.my_tank.stop=False
               
                elif event.key==pygame.K_DOWN:
                    # 切换方向
                   MainGame.my_tank.direction='D'# 开启坦克开关
                   MainGame.my_tank.stop=False

                elif event.key==pygame.K_SPACE:
                    # 我方子弹列表的大小小于等于3的时候才可创建
                    if len(MainGame.myBulletList)<3:
                        # 创建我方坦克的子弹
                        myBullet=Bullet(MainGame.my_tank)
                        MainGame.myBulletList.append(myBullet)

            # 如果松开键盘,修改开关,坦克停止移动
            if event.type==pygame.KEYUP:
                # 判断松开的键是否为方向键
                if event.key==pygame.K_LEFT or event.key==pygame.K_RIGHT or event.key==pygame.K_UP or event.key==pygame.K_DOWN:
                    MainGame.my_tank.stop=True

class Tank(BaseItem):
    def __init__(self,left,top):
        # 保存加载的图片
        self.images={
            'U':pygame.image.load('坦克大战\p1tankU.gif'),
            'D':pygame.image.load('坦克大战\p1tankD.gif'),
            'L':pygame.image.load('坦克大战\p1tankL.gif'),
            'R':pygame.image.load('坦克大战\p1tankR.gif')
                    }

    # 方向
        self.direction='U'
        # 根据当前图片的方向获取图片
        self.image=self.images[self.direction]
        # 根据图片获取区域
        self.rect=self.image.get_rect()
        # 设置区域的left和top
        self.rect.left=left
        self.rect.top=top
        self.speed=5
        # 坦克移动的开关
        self.stop=True
        # 坦克存活状态
        self.live=True

    #移动
    def move(self):
        if self.direction=='L':
            if self.rect.left>0:
                self.rect.left-=self.speed
        elif self.direction=='U':
            if self.rect.top>0:
                self.rect.top-=self.speed
        elif self.direction=='D':
            if self.rect.top+self.rect.height<SCREEN_HEIGHT:
                self.rect.top+=self.speed
        elif self.direction=='R':
            if self.rect.left+self.rect.height<SCREEN_WIDTH:
                self.rect.left+=self.speed

    #射击
    def shot(self):
        return Bullet(self)
    #展示坦克的方法
    def displayTank(self):
        # 获取展示的对象
        self.image=self.images[self.direction]
        # 调用blit方法展示
        MainGame.window.blit(self.image,self.rect)
#我方坦克
class MyTank(Tank):
    def __init__(self):
        pass

#敌方坦克
class EnemyTank(Tank):
    def __init__(self,left,top,speed):
        # 调用父类的初始化方法
        super(EnemyTank,self).__init__(left,top)
        self.images={
                    'U':pygame.image.load('坦克大战\enemy1U.gif'),
                    'D':pygame.image.load('坦克大战\enemy1D.gif'),
                    'L':pygame.image.load('坦克大战\enemy1L.gif'),
                    'R':pygame.image.load('坦克大战\enemy1R.gif'),
                    }

        # 敌方坦克的方向随机生成
        self.direction=self.randDirection()
        # 根据方向获取图片
        self.image=self.images[self.direction]
        # 区域
        self.rect=self.image.get_rect()
        # 对left和top赋值
        self.rect.left=left
        self.rect.top=top
        # 速度
        self.speed=speed
        # 移动开关键
        self.flag=True
        # 步数
        self.step=60

    def randDirection(self):
        num=random.randint(1,4)
        if num==1:
            return 'U'
        elif num==2:
            return 'D'
        elif num==3:
            return 'L'
        elif num==4:
            return 'R'

    def ranMove(self):
        if self.step<=0:
            # 修改方向
            self.direction=self.randDirection()
            # 步数复位
            self.step=60
        else:
            self.move()
            # 让步数递减
            self.step-=1

    def shot(self):
        num=random.randint(1,100)
        if num<3:
            return Bullet(self)
#子弹类
class Bullet(BaseItem):
    def __init__(self,tank):
        # 加载图片
        self.image=pygame.image.load('坦克大战\enemymissile.gif')
        # 坦克方向决定子弹方向
        self.direction=tank.direction
        # 获取区域
        self.rect=self.image.get_rect()
        # 子弹的left和top与方向有关
        if self.direction=='U':
            self.rect.left=tank.rect.left+tank.rect.width/2-self.rect.width/2
            self.rect.top=tank.rect.top-self.rect.height
        if self.direction=='D':
            self.rect.left=tank.rect.left+tank.rect.width/2-self.rect.width/2
            self.rect.top=tank.rect.top+self.rect.height
        if self.direction=='L':
            self.rect.left=tank.rect.left-tank.rect.width/2-self.rect.width/2
            self.rect.top=tank.rect.top+self.rect.width/2-self.rect.width/2
        if self.direction=='R':
            self.rect.left=tank.rect.left+tank.rect.width
            self.rect.top=tank.rect.top+self.rect.width/2-self.rect.width/2
        # 子弹速度
        self.speed=6
        # 子弹的状态,若碰到墙壁,则修改此状态
        self.live=True

    #移动
    def move(self):
        if self.direction=='U':
            if self.rect.top>0:
                self.rect.top-=self.speed
            else:
                # 修改子弹状态
                self.live=False
        elif self.direction=='R':
            if self.rect.left+self.rect.width<SCREEN_WIDTH:
                self.rect.left+=self.speed
            else:
                self.live=False
        elif self.direction=='D':
            if self.rect.top+self.rect.height<SCREEN_HEIGHT:
                self.rect.top+=self.speed
            else:
                self.live=False

        elif self.direction=='L':
            if self.rect.left>0:
                self.rect.left-=self.speed
            else:
                self.live=False

        
    #展示子弹的方法
    def displayBullet(self):
        # 将图片展示到窗口
        MainGame.window.blit(self.image,self.rect)

    # 我方子弹与敌方坦克碰撞
    def myBullet_hit_enemyTank(self):
        # 循环遍历敌方坦克列表,判断是否碰撞
        for enemyTank in MainGame.enemyTankList:
            if pygame.sprite.collide_rect(enemyTank,self):
                # 修改敌方坦克以及我方子弹状态
                enemyTank.live=False
                self.live=False
                # 创建爆炸对象
                explode=Explode(enemyTank)
                # 将爆炸对象添加到列表中
                MainGame.explodeList.append(explode)

class Wall():
    def __init__(self):
        pass
    #展示墙壁的方法
    def displayWall(self):
        pass
class Explode():
    def __init__(self,tank):
        # 爆炸的位置由子弹打中坦克的位置决定
        self.rect=tank.rect
        self.images=[
                    pygame.image.load(r'坦克大战\blast0.gif'),
                    pygame.image.load(r'坦克大战\blast1.gif'),
                    pygame.image.load(r'坦克大战\blast2.gif'),
                    pygame.image.load(r'坦克大战\blast3.gif'),
                    pygame.image.load(r'坦克大战\blast4.gif'),]

        self.step=0
        self.image=self.images[self.step]
        # 状态
        self.live=True
    #展示爆炸效果的方法
    def displayExplode(self):
        if self.step<len(self.images):
            self.image=self.images[self.step]
            self.step+=1   
            # 添加到主窗口
            MainGame.window.blit(self.image,self.rect)
        else:
            # 修改状态
            self.live=False
            self.step=0  

class Music():
    def __init__(self):
        pass
    #播放音乐
    def play(self):
        pass

if __name__=='__main__':
    MainGame().startGame()


Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 27218楼
Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 27219楼
JAVA 全系列/第十一阶段:分布式RPC调用和分布式文件存储/FastDFS 27220楼
Python 全系列/第十九阶段:数据分析-数据管理/jupyter notebook_介绍和使用 27221楼
JAVA 全系列/(隐藏)第二十三阶段:数字货币交易所项目/微服务公共依赖common的搭建 27222楼
Python 全系列/第十九阶段:数据分析-数据管理/ipython介绍 27224楼

from tkinter.filedialog import *       # 导入模块
from tkinter.colorchooser import *
from tkinter.filedialog import *

win_width = 900
win_height = 450
class Appliacation(Frame):
    '''一个经典的GUI程序写法'''
    def __init__(self, master=None, bgcolor="#0000000"):
        super().__init__(master)        # super()代表的是父类的定义,而不是对象
        self.master = master
        self.pack()     # 布局管理器
        self.bgcolor = bgcolor
        self.x = 0
        self.y = 0
        self.fgcolor = "#ff0000"
        self.lastDraw = 0
        self.startDrawFlag = False
        self.creatWidgt()


    def creatWidgt(self):
        # 创建绘画区
        drawpad = Canvas(root, width=win_width, height=win_height*0.9, bg=["pink"])
        drawpad.pack()

        # 创建按钮
        btn_start = Button(root, text="开始", name="start")
        btn_start.pack(padx=10,side="left")
        btn_pen = Button(root, text="画笔", name="pen")
        btn_pen.pack(padx=10, side="left")
        btn_rect = Button(root, text="矩形", name="rect")
        btn_rect.pack(padx=10, side="left")
        btn_clear = Button(root, text="清屏", name="clear")
        btn_clear.pack(padx=10, side="left")
        btn_erasor = Button(root, text="橡皮擦", name="erasor")
        btn_erasor.pack(padx=10, side="left")
        btn_line = Button(root, text="直线", name="line")
        btn_line.pack(padx=10, side="left")
        btn_lineArrow = Button(root, text="箭头直线", name="lineArrow")
        btn_lineArrow.pack(padx=10, side="left")
        btn_color = Button(root, text="颜色", name="color")
        btn_color.pack(padx=10, side="left")

        btn_pen.bind_class("<Button>","<1>",self.eventManager)
        self.drawpad.bind("<ButtonRalease-1>", self.stopDraw)


    def eventManager(self,event):
        name = event.widget.winfo_name()
        print(name)
        if name=="line":
            self.drawpad.bind("<B1-Motion>", self.myline)
        elif name=="lineArrow":
            self.drawpad.bind("<B1-Motion>", self.lineArrow)

    def stopDraw(self,event):
        self.startDrawFlag = False


    def myline(self,event):
        self.drawpad.delete(self.lastDraw)
        if not self.startDrawFlag:
            self.startDrawFlag = True
            self.x = event.x
            self.y = event.y

        self.lastDraw = self.drawpad.create_line(self.x, self.y, event.x, event.y, fill=self.fgcolor)

    def lineArrow(self,event):
        self.drawpad.delete(self.lastDraw)
        if not self.startDrawFlag:
            self.startDrawFlag = True
            self.x = event.x
            self.y = event.y

        self.lastDraw = self.drawpad.create_line(self.x, self.y, event.x, event.y,arrow=LAST,fill=self.fgcolor)



if __name__ == "__main__":
    root = Tk()
    root.title("绘画软件")
    root.geometry(str(win_width) + "x" + str(win_height)+"+500+300")
    app = Appliacation(master=root)

    root.mainloop()

我是按照视频里边老师讲解的顺序一点一点跟着敲的,但是有点问题现在。一直报错,报错的原因如下:

blob.png

希望老师帮我指点一下!先谢谢了。

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 27225楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637