首先我将原来springboot版本升级到2.7.9,spring的docker分层和启动受到了影响,这个在docker镜像大小问题已经讲过,不再赘述,因为维护的人变成为一个人,因此我需要将各代码的版本进行统一,方便维护。
之所以没有继续往生升,是因为spring再往后的版本对jdk的要求不再是jdk1.8了。
17 Cannot find current proxy: Set ‘exposeProxy’ property on Advised to ‘true’
升级spring到2.7.9,有些写法就不支持了。需要在启动类添加@EnableAspectJAutoProxy(exposeProxy = true)
@Slf4j
@SpringBootApplication
@EnableDiscoveryClient
@ComponentScan(basePackages = { "com.tt.*" })
@MapperScan("com.tt.**.dao")
@EnableAsync
@EnableL2Cache
@EnableScheduling
@EnableAspectJAutoProxy(exposeProxy = true)
public class FundServerApplication {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(FundServerApplication.class);
app.setAllowCircularReferences(Boolean.TRUE);
Environment env = app.run(args).getEnvironment();
InetAddress address = null;
try {
address = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
log.info("启动成功!!");
log.info("acc-fund-server地址: \thttp://"+address.getHostAddress()+":{}", env.getProperty("server.port"));
}
}
16 Could not determine which parameter to assign generated keys to
因为mybatis-plus是通过@TableId(type= IdType.AUTO)
,因此在mybatis-plus中就不需要useGeneratedKeys="true" keyProperty="id"
配置了。
int batchInsert(@Param("productVersionId") Integer productVersionId,@Param("productCategory") String productCategory, @Param("permissionIds") List<Integer> permissionIds);
<insert id="batchInsert" useGeneratedKeys="true" keyProperty="id">
insert into mbms_product_version_permission(product_version_id,permission_id,product_category)
values
<foreach collection="permissionIds" item="item" separator=",">
(#{productVersionId}, #{item}, #{productCategory})
</foreach>
</insert>
虽然报下面的错误,但是数据却插入到数据库中了
Caused by: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: Could not determine which parameter to assign generated keys to. Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). Specified key properties are [id] and available parameters are [param3, param1, permissionIds, productVersionId, productCategory, param2]
at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:88)
at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processAfter(Jdbc3KeyGenerator.java:71)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:51)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
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.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)
at com.sun.proxy.$Proxy298.update(Unknown Source)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
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.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)
at com.sun.proxy.$Proxy297.update(Unknown Source)
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.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)
at com.sun.proxy.$Proxy297.update(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:181)
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.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)
... 113 more
Caused by: org.apache.ibatis.executor.ExecutorException: Could not determine which parameter to assign generated keys to. Note that when there are multiple parameters, 'keyProperty' must include the parameter name (e.g. 'param.id'). Specified key properties are [id] and available parameters are [param3, param1, permissionIds, productVersionId, productCategory, param2]
at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.getAssignerForParamMap(Jdbc3KeyGenerator.java:189)
at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.assignKeysToParamMap(Jdbc3KeyGenerator.java:157)
at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.assignKeys(Jdbc3KeyGenerator.java:97)
at org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator.processBatch(Jdbc3KeyGenerator.java:85)
... 146 more
15 .BindingException: Invalid bound statement (not found):
这里要注意的是mybatis-plus的配置与mybatis不一样
mybatis-plus:
global-config:
db-config:
id-type: auto
db-type: mysql
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath*:com/whty/**/mapping/*.xml
14 invalid version format: UNSUPPORTED
08:42:25.029 ERROR o.s.b.a.w.r.error.AbstractErrorWebExceptionHandler - [a55ff6b0-3] 500 Server Error for HTTP GET "/api/eayc/user/info?userId=545468a1275f448d8783f7db0720243d"
java.lang.IllegalArgumentException: invalid version format: UNSUPPORTED
at io.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:123)
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
*__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
*__checkpoint ⇢ org.springframework.boot.actuate.metrics.web.reactive.server.MetricsWebFilter [DefaultWebFilterChain]
*__checkpoint ⇢ HTTP GET "/api/eayc/user/info?userId=545468a1275f448d8783f7db0720243d" [ExceptionHandlingWebHandler]
Original Stack Trace:
at io.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:123)
at io.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:85)
at io.netty.handler.codec.http.HttpResponseDecoder.createMessage(HttpResponseDecoder.java:155)
at io.netty.handler.codec.http.HttpObjectDecoder.decode(HttpObjectDecoder.java:276)
at io.netty.handler.codec.http.HttpClientCodec$Decoder.decode(HttpClientCodec.java:239)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
08:42:25.508 INFO com.alibaba.nacos.common.remote.client - [9a7f482a-f44d-4f35-9bf7-dae51e04416c] Receive server push request, request = NotifySubscriberRequest, requestId = 656
08:42:25.509 INFO com.alibaba.nacos.common.remote.client - [9a7f482a-f44d-4f35-9bf7-dae51e04416c] Ack server push request, request = NotifySubscriberRequest, requestId = 656
13 ERROR o.a.dubbo.registry.client.metadata.MetadataUtils
2023-07-11 12:30:34 ERROR o.a.dubbo.registry.client.metadata.MetadataUtils [DUBBO] Failed to get app metadata for revision 5d3409560ac299c803df8c43a3547f45 for type local from instance 192.168.1.122:30896, dubbo version: 3.0.12, current host: 192.168.43.103
org.apache.dubbo.rpc.RpcException: Fail to create remoting client for service(dubbo://192.168.1.122:30896/org.apache.dubbo.metadata.MetadataService?codec=dubbo&connections=1&corethreads=2&dubbo=2.0.2&group=eayc-user-server&heartbeat=60000&port=30896&protocol=dubbo&release=3.0.12&retries=0&side=provider&threadpool=cached&threads=100&timeout=5000&version=1.0.0): client(url: dubbo://192.168.1.122:30896/org.apache.dubbo.metadata.MetadataService?codec=dubbo&connections=1&corethreads=2&dubbo=2.0.2&group=eayc-user-server&heartbeat=60000&port=30896&protocol=dubbo&release=3.0.12&retries=0&side=provider&threadpool=cached&threads=100&timeout=5000&version=1.0.0) failed to connect to server /192.168.1.122:30896 client-side timeout 3000ms (elapsed: 3012ms) from netty client 192.168.43.103 using dubbo version 3.0.12
at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol.initClient(DubboProtocol.java:607)
at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol.getClients(DubboProtocol.java:431)
at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol.protocolBindingRefer(DubboProtocol.java:404)
at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol.refer(DubboProtocol.java:395)
at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:78)
at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:77)
at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:74)
at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52)
at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
at org.apache.dubbo.registry.client.metadata.MetadataUtils.referProxy(MetadataUtils.java:142)
at org.apache.dubbo.registry.client.metadata.MetadataUtils.getRemoteMetadata(MetadataUtils.java:170)
at org.apache.dubbo.registry.client.AbstractServiceDiscovery.getRemoteMetadata(AbstractServiceDiscovery.java:173)
at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.doOnEvent(ServiceInstancesChangedListener.java:152)
at org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener.onEvent(ServiceInstancesChangedListener.java:112)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribeURLs(ServiceDiscoveryRegistry.java:316)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.doSubscribe(ServiceDiscoveryRegistry.java:216)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistry.subscribe(ServiceDiscoveryRegistry.java:184)
at org.apache.dubbo.registry.ListenerRegistryWrapper.subscribe(ListenerRegistryWrapper.java:111)
at org.apache.dubbo.registry.integration.DynamicDirectory.subscribe(DynamicDirectory.java:180)
at org.apache.dubbo.registry.client.ServiceDiscoveryRegistryDirectory.subscribe(ServiceDiscoveryRegistryDirectory.java:108)
at org.apache.dubbo.registry.integration.RegistryProtocol.doCreateInvoker(RegistryProtocol.java:570)
at org.apache.dubbo.registry.integration.InterfaceCompatibleRegistryProtocol.getServiceDiscoveryInvoker(InterfaceCompatibleRegistryProtocol.java:65)
at org.apache.dubbo.registry.client.migration.MigrationInvoker.refreshServiceDiscoveryInvoker(MigrationInvoker.java:436)
at org.apache.dubbo.registry.client.migration.MigrationInvoker.migrateToForceApplicationInvoker(MigrationInvoker.java:205)
at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.refreshInvoker(MigrationRuleHandler.java:76)
at org.apache.dubbo.registry.client.migration.MigrationRuleHandler.doMigrate(MigrationRuleHandler.java:57)
at org.apache.dubbo.registry.client.migration.MigrationRuleListener.onRefer(MigrationRuleListener.java:243)
at org.apache.dubbo.registry.integration.RegistryProtocol.interceptInvoker(RegistryProtocol.java:535)
at org.apache.dubbo.registry.integration.RegistryProtocol.doRefer(RegistryProtocol.java:505)
at org.apache.dubbo.registry.integration.RegistryProtocol.refer(RegistryProtocol.java:487)
at org.apache.dubbo.qos.protocol.QosProtocolWrapper.refer(QosProtocolWrapper.java:78)
at org.apache.dubbo.rpc.protocol.ProtocolListenerWrapper.refer(ProtocolListenerWrapper.java:74)
at org.apache.dubbo.rpc.cluster.filter.ProtocolFilterWrapper.refer(ProtocolFilterWrapper.java:71)
at org.apache.dubbo.rpc.protocol.ProtocolSerializationWrapper.refer(ProtocolSerializationWrapper.java:52)
at org.apache.dubbo.rpc.Protocol$Adaptive.refer(Protocol$Adaptive.java)
at org.apache.dubbo.config.ReferenceConfig.createInvokerForRemote(ReferenceConfig.java:515)
at org.apache.dubbo.config.ReferenceConfig.createProxy(ReferenceConfig.java:422)
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:287)
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:219)
at org.apache.dubbo.config.utils.SimpleReferenceCache.get(SimpleReferenceCache.java:129)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:389)
at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4707)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:369)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:160)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:132)
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:111)
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:100)
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:45)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.whty.acc.mms.server.MmsServerApplication.main(MmsServerApplication.java:29)
Caused by: org.apache.dubbo.remoting.RemotingException: client(url: dubbo://192.168.1.122:30896/org.apache.dubbo.metadata.MetadataService?codec=dubbo&connections=1&corethreads=2&dubbo=2.0.2&group=eayc-user-server&heartbeat=60000&port=30896&protocol=dubbo&release=3.0.12&retries=0&side=provider&threadpool=cached&threads=100&timeout=5000&version=1.0.0) failed to connect to server /192.168.1.122:30896 client-side timeout 3000ms (elapsed: 3012ms) from netty client 192.168.43.103 using dubbo version 3.0.12
at org.apache.dubbo.remoting.transport.netty4.NettyClient.doConnect(NettyClient.java:195)
at org.apache.dubbo.remoting.transport.AbstractClient.connect(AbstractClient.java:218)
at org.apache.dubbo.remoting.transport.AbstractClient.<init>(AbstractClient.java:75)
at org.apache.dubbo.remoting.transport.netty4.NettyClient.<init>(NettyClient.java:90)
at org.apache.dubbo.remoting.transport.netty4.NettyTransporter.connect(NettyTransporter.java:40)
at org.apache.dubbo.remoting.Transporter$Adaptive.connect(Transporter$Adaptive.java)
at org.apache.dubbo.remoting.Transporters.connect(Transporters.java:74)
at org.apache.dubbo.remoting.exchange.support.header.HeaderExchanger.connect(HeaderExchanger.java:39)
at org.apache.dubbo.remoting.exchange.Exchangers.connect(Exchangers.java:107)
at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol.initClient(DubboProtocol.java:605)
... 59 common frames omitted
12 [DUBBO] qos-server can not bind localhost:22222
执行命令netstat -ano|findstr 22222
,端口确实被占用
2023-07-11 11:21:12 INFO org.apache.dubbo.rpc.model.ModuleModel [DUBBO] Dynamically registering consumer model eayc-user-server/org.apache.dubbo.metadata.MetadataService:1.0.0 into model Dubbo Module[1.1.0], dubbo version: 3.0.12, current host: 127.0.0.1
2023-07-11 11:21:12 ERROR org.apache.dubbo.qos.server.Server [DUBBO] qos-server can not bind localhost:22222, dubbo version: 3.0.12, current host: 127.0.0.1
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:579)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356)
at io.netty.util.concurrent.AbstractEventExecutor.runTask$$$capture(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
11 java.lang.IllegalArgumentException: invalid version format: UNSUPPORTED
15:30:11.692 WARN reactor.netty.http.client.HttpClientConnect - [aaf94de9-1, L:/192.168.1.104:54169 - R:/192.168.1.104:30896] The connection observed an error
java.lang.IllegalArgumentException: invalid version format: UNSUPPORTED
at io.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:123)
at io.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:85)
at io.netty.handler.codec.http.HttpResponseDecoder.createMessage(HttpResponseDecoder.java:155)
at io.netty.handler.codec.http.HttpObjectDecoder.decode(HttpObjectDecoder.java:276)
at io.netty.handler.codec.http.HttpClientCodec$Decoder.decode(HttpClientCodec.java:239)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:529)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:468)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
10 批量找到要修改的地方
因为从mybatis升级到mybatis-plus,要改动的地方太多,可以通过正则找到要修改的地方,再统一调整。
9 idea根据后缀查询不到数据
找到find.xml
注意下面的内容,这个*
不能少
8 代码逻辑混乱的问题
下面代码看起来觉得很是别扭,这个就是宝马头上插奔驰的标,原本接口是要高内聚低耦合,为什么不将红色部分的代码,在EaycCompanyUserService
中封装接口呢?
封装一个接口,但那里可以调用,而不是什么都从头写到尾,这么写代码的好处是,这种不能开除,开除了,你改他的代码,估计会苦,稍微一动出问题,还麻烦。码农就是这么来的。
@Override
public EaycCompanyUserInfo selectById(String id) {
MPJLambdaWrapper<EaycCompanyUser> mpjLambdaWrapper = new MPJLambdaWrapper<>();
mpjLambdaWrapper.selectAll(EaycCompanyUser.class)
.selectAs(EaycCompany::getName, EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getType,EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getTaxNo,EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getTel,EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getProvince,EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getCity,EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getArea,EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getAddress,EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getStatus,EaycCompanyUserInfo::getName)
.selectAs(EaycCompany::getCreatorId,EaycCompanyUserInfo::getName)
.innerJoin(EaycCompany.class,EaycCompany::getId,EaycCompanyUser::getCompanyId);
mpjLambdaWrapper.eq(EaycCompanyUser::getId, id);
return selectJoinOne(EaycCompanyUserInfo.class,mpjLambdaWrapper);
}
调用感觉就好多了,下面没有对空指针进行判断。
@Override
public EnterpriseMemberDto findUser(String id) {
EnterpriseMemberDto memberDto = new EnterpriseMemberDto();
EaycCompanyUserInfo info = eaycCompanyUserService.selectById(id);
BeanUtils.copyProperties(info, memberDto);
memberDto.setId(id);
memberDto.setCompanyId(info.getId());
return memberDto;
}
7 Could not autowire. No beans of ‘RabbitTemplate’ type found.
解决Could not autowire. No beans of ‘RabbitTemplate‘ type found.报错,让我将springboot版本,回到过去那是不可能的了。那么如何解决这个问题呢?
解决方案还是出来idea设置,入下图解决
6 Disconnected from the target VM, address: ‘127.0.0.1:60041’, transport: ‘socket’
20:11:40.572 INFO o.s.c.b.c.PropertySourceBootstrapConfiguration - Located property source: [BootstrapPropertySource {name='bootstrapProperties-eayc-user-server-local.yml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-eayc-user-server.yml,DEFAULT_GROUP'}, BootstrapPropertySource {name='bootstrapProperties-eayc-user-server,DEFAULT_GROUP'}]
Disconnected from the target VM, address: '127.0.0.1:60041', transport: 'socket'
Process finished with exit code 1
端口占用?netstat -ano | findstr 60041
,没有占用,问题应该不在这里。这个问题,应该是日志被隐藏了。将工程打成jar,执行java -jar eayc-user-server.jar
,出现了下面的异常
这个问题应该跟字符集有关系,修改启动命令`java -jar -Dfile.encoding=utf-8 eayc-user-server.jar,配置文件加载进来了,但是启动却失败了。
配置日志
logging:
config: http://${spring.cloud.nacos.config.server-addr}/nacos/v1/cs/configs?group=DEFAULT_GROUP&tenant=${spring.cloud.nacos.config.namespace}&dataId=eayc-user-logback.xml
看到的错误日志是
17:57:20.856 ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalStateException: Failed to check the status of the service com.whty.acc.user.api.service.AccUserDubboService. No provider available for the service com.whty.acc.user.api.service.AccUserDubboService from the url consumer://192.168.124.12/com.whty.acc.user.api.service.AccUserDubboService?application=eayc-user-server&background=false&dubbo=2.0.2&interface=com.whty.acc.user.api.service.AccUserDubboService&methods=updateCompanyUserPayStatus,findCurrentCompanyByEaycUserId,findAccUserAccountSetInfo,tokenVerify&pid=20504&qos.enable=false®ister.ip=192.168.124.12&release=3.0.12&revision=1.8.0&side=consumer&sticky=false×tamp=1687514236869 to the consumer 192.168.124.12 use dubbo version 3.0.12
at org.apache.dubbo.config.ReferenceConfig.checkInvokerAvailable(ReferenceConfig.java:565)
at org.apache.dubbo.config.ReferenceConfig.init(ReferenceConfig.java:296)
at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:219)
at org.apache.dubbo.config.utils.SimpleReferenceCache.destroyReference(SimpleReferenceCache.java:262)
at org.apache.dubbo.config.utils.SimpleReferenceCache.destroy(SimpleReferenceCache.java:215)
at org.apache.dubbo.config.utils.SimpleReferenceCache.destroy(SimpleReferenceCache.java:239)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.lambda$referServices$6(DefaultModuleDeployer.java:394)
at java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4707)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.referServices(DefaultModuleDeployer.java:369)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.startSync(DefaultModuleDeployer.java:160)
at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:132)
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onContextRefreshedEvent(DubboDeployApplicationListener.java:111)
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:100)
at org.apache.dubbo.config.spring.context.DubboDeployApplicationListener.onApplicationEvent(DubboDeployApplicationListener.java:45)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.whty.eayc.user.server.EaycUserServerApplication.main(EaycUserServerApplication.java:28)
17:57:20.856 INFO c.whty.eayc.user.server.EaycUserServerApplication - EaycUserServer start finish
17:57:21.014 WARN com.alibaba.nacos.common.notify.NotifyCenter - [NotifyCenter] Start destroying Publisher
17:57:21.014 WARN com.alibaba.nacos.common.http.HttpClientBeanHolder - [HttpClientBeanHolder] Start destroying common HttpClient
17:57:21.014 WARN com.alibaba.nacos.common.notify.NotifyCenter - [NotifyCenter] Destruction of the end
Disconnected from the target VM, address: '127.0.0.1:58382', transport: 'socket'
Process finished with exit code 1
从上面来看,应该dubbo配置出了问题,并不是说没有提供者,就客户端就不能启动,修改配置如下,即可正常启动
nacos:
server-addr: 127.0.0.1:8848
namespace: dj
dubbo-namespace: dubbo-dev
spring:
application:
name: eayc-user-server
cloud:
nacos:
config:
server-addr: ${nacos.server-addr}
file-extension: yml
namespace: ${nacos.namespace}
discovery:
server-addr: ${nacos.server-addr}
namespace: ${nacos.namespace}
dubbo:
application:
id: eayc-user-server
name: eayc-user-server
register-mode: instance
service-discovery:
migration: FORCE_APPLICATION
scan:
base-packages: com.whty.eayc.user.dubbo
protocols:
dubbo:
name: dubbo
port: 30896
registry:
address: nacos://${nacos.server-addr}
parameters:
namespace: ${nacos.dubbo-namespace}
cloud:
subscribed-services: /
consumer:
check: false
5 sun.misc.BASE64Encoder is internal proprietary API and may be removed in a future release
解决方案为
import java.util.Base64;
public class JDKBase64Util {
/**
* BASE64解密
*/
public static byte[] decryptBASE64(String key) throws Exception {
return Base64.getDecoder().decode(key);
}
/**
* BASE64加密
*/
public static String encryptBASE64(byte[] key) throws Exception {
return Base64.getEncoder().encodeToString(key);
}
}
4 Failed to start bean ‘documentationPluginsBootstrapper’
看下面的日志应该出现在springfox与springboot不兼容的问题。解决方案参考了IDEA报错之Failed to start bean ‘documentationPluginsBootstrapper‘问题及解决方案
配置
mvc:
pathmatch:
matching-strategy: ANT_PATH_MATCHER
2023-06-21 13:16:36 ERROR org.springframework.boot.SpringApplication Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
at java.lang.Iterable.forEach(Iterable.java:75)
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.whty.einv.user.server.UserServerApplication.main(UserServerApplication.java:32)
Caused by: java.lang.NullPointerException: null
at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56)
at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113)
at springfox.documentation.spi.service.contexts.Orderings.lambda$byPatternsCondition$3(Orderings.java:89)
at java.util.Comparator.lambda$comparing$77a9974f$1(Comparator.java:469)
at java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
at java.util.TimSort.sort(TimSort.java:234)
at java.util.Arrays.sort(Arrays.java:1512)
at java.util.ArrayList.sort(ArrayList.java:1462)
at java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:387)
at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
at java.util.stream.Sink$ChainedReference.end(Sink.java:258)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider.requestHandlers(WebMvcRequestHandlerProvider.java:81)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.withDefaults(AbstractDocumentationPluginsBootstrapper.java:107)
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.buildContext(AbstractDocumentationPluginsBootstrapper.java:91)
at springfox.documentation.spring.web.plugins.AbstractDocumentationPluginsBootstrapper.bootstrapDocumentationPlugins(AbstractDocumentationPluginsBootstrapper.java:82)
at springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper.start(DocumentationPluginsBootstrapper.java:100)
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
3 服务器启动的时候报错
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/repository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.17.2/log4j-slf4j-impl-2.17.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
2 pom中有jar的引用,但是代码还是报警
这个问题是idea的缓存导致的。
上面的问题idea缓存问题,点击 Invalidate Caches / Restart 重启idea搞定。
1 The dependencies of some of the beans in the application context form a cycle:
工程里面循环调用的地方,还不少。
解决这个问题方案再启动类增加`