开发问题记录20230502

7 WebFlux集成Swagger

7.1异常

2023-05-27 22:23:28,115 ERROR [traceId=, spanId=] 2023-05-27 22:23:28 [main] [ERROR] - Application run failed
java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration.propertySourcesPlaceholderConfigurer
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:193)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:153)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:343)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564)
at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:63)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:782)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:774)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:339)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
at com.monkey.springboottemplate.SpringBootTemplateApplication.main(SpringBootTemplateApplication.java:20)
Caused by: java.lang.IllegalStateException: Failed to introspect Class [springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration] from ClassLoader [sun.misc.Launcher A p p C l a s s L o a d e r @ 18 b 4 a a c 2 ] a t o r g . s p r i n g f r a m e w o r k . u t i l . R e f l e c t i o n U t i l s . g e t D e c l a r e d M e t h o d s ( R e f l e c t i o n U t i l s . j a v a : 481 ) a t o r g . s p r i n g f r a m e w o r k . u t i l . R e f l e c t i o n U t i l s . d o W i t h M e t h o d s ( R e f l e c t i o n U t i l s . j a v a : 358 ) a t o r g . s p r i n g f r a m e w o r k . u t i l . R e f l e c t i o n U t i l s . g e t U n i q u e D e c l a r e d M e t h o d s ( R e f l e c t i o n U t i l s . j a v a : 414 ) a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . l a m b d a AppClassLoader@18b4aac2] at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358) at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda AppClassLoader@18b4aac2]atorg.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481)atorg.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358)atorg.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambdagetTypeForFactoryMethod 2 ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 747 ) a t j a v a . u t i l . c o n c u r r e n t . C o n c u r r e n t H a s h M a p . c o m p u t e I f A b s e n t ( C o n c u r r e n t H a s h M a p . j a v a : 1660 ) a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . g e t T y p e F o r F a c t o r y M e t h o d ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 746 ) a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . d e t e r m i n e T a r g e t T y p e ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 685 ) a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . p r e d i c t B e a n T y p e ( A b s t r a c t A u t o w i r e C a p a b l e B e a n F a c t o r y . j a v a : 656 ) a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . A b s t r a c t B e a n F a c t o r y . i s F a c t o r y B e a n ( A b s t r a c t B e a n F a c t o r y . j a v a : 1670 ) a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t L i s t a b l e B e a n F a c t o r y . d o G e t B e a n N a m e s F o r T y p e ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 570 ) a t o r g . s p r i n g f r a m e w o r k . b e a n s . f a c t o r y . s u p p o r t . D e f a u l t L i s t a b l e B e a n F a c t o r y . g e t B e a n N a m e s F o r T y p e ( D e f a u l t L i s t a b l e B e a n F a c t o r y . j a v a : 542 ) a t o r g . s p r i n g f r a m e w o r k . b o o t . a u t o c o n f i g u r e . c o n d i t i o n . O n B e a n C o n d i t i o n . c o l l e c t B e a n N a m e s F o r T y p e ( O n B e a n C o n d i t i o n . j a v a : 238 ) a t o r g . s p r i n g f r a m e w o r k . b o o t . a u t o c o n f i g u r e . c o n d i t i o n . O n B e a n C o n d i t i o n . g e t B e a n N a m e s F o r T y p e ( O n B e a n C o n d i t i o n . j a v a : 231 ) a t o r g . s p r i n g f r a m e w o r k . b o o t . a u t o c o n f i g u r e . c o n d i t i o n . O n B e a n C o n d i t i o n . g e t B e a n N a m e s F o r T y p e ( O n B e a n C o n d i t i o n . j a v a : 221 ) a t o r g . s p r i n g f r a m e w o r k . b o o t . a u t o c o n f i g u r e . c o n d i t i o n . O n B e a n C o n d i t i o n . g e t M a t c h i n g B e a n s ( O n B e a n C o n d i t i o n . j a v a : 169 ) a t o r g . s p r i n g f r a m e w o r k . b o o t . a u t o c o n f i g u r e . c o n d i t i o n . O n B e a n C o n d i t i o n . g e t M a t c h O u t c o m e ( O n B e a n C o n d i t i o n . j a v a : 144 ) a t o r g . s p r i n g f r a m e w o r k . b o o t . a u t o c o n f i g u r e . c o n d i t i o n . S p r i n g B o o t C o n d i t i o n . m a t c h e s ( S p r i n g B o o t C o n d i t i o n . j a v a : 47 ) . . . 18 c o m m o n f r a m e s o m i t t e d C a u s e d b y : j a v a . l a n g . N o C l a s s D e f F o u n d E r r o r : o r g / s p r i n g f r a m e w o r k / w e b / s e r v l e t / H a n d l e r M a p p i n g a t j a v a . l a n g . C l a s s . g e t D e c l a r e d M e t h o d s 0 ( N a t i v e M e t h o d ) a t j a v a . l a n g . C l a s s . p r i v a t e G e t D e c l a r e d M e t h o d s ( C l a s s . j a v a : 2701 ) a t j a v a . l a n g . C l a s s . g e t D e c l a r e d M e t h o d s ( C l a s s . j a v a : 1975 ) a t o r g . s p r i n g f r a m e w o r k . u t i l . R e f l e c t i o n U t i l s . g e t D e c l a r e d M e t h o d s ( R e f l e c t i o n U t i l s . j a v a : 463 ) . . . 34 c o m m o n f r a m e s o m i t t e d C a u s e d b y : j a v a . l a n g . C l a s s N o t F o u n d E x c e p t i o n : o r g . s p r i n g f r a m e w o r k . w e b . s e r v l e t . H a n d l e r M a p p i n g a t j a v a . n e t . U R L C l a s s L o a d e r . f i n d C l a s s ( U R L C l a s s L o a d e r . j a v a : 387 ) a t j a v a . l a n g . C l a s s L o a d e r . l o a d C l a s s ( C l a s s L o a d e r . j a v a : 418 ) a t s u n . m i s c . L a u n c h e r 2(AbstractAutowireCapableBeanFactory.java:747) at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:746) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:685) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:656) at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1670) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:570) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:542) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:238) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:231) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:221) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:169) at org.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:144) at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ... 18 common frames omitted Caused by: java.lang.NoClassDefFoundError: org/springframework/web/servlet/HandlerMapping at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.getDeclaredMethods(Class.java:1975) at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ... 34 common frames omitted Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.HandlerMapping at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher 2(AbstractAutowireCapableBeanFactory.java:747)atjava.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:746)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:685)atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:656)atorg.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1670)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:570)atorg.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:542)atorg.springframework.boot.autoconfigure.condition.OnBeanCondition.collectBeanNamesForType(OnBeanCondition.java:238)atorg.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:231)atorg.springframework.boot.autoconfigure.condition.OnBeanCondition.getBeanNamesForType(OnBeanCondition.java:221)atorg.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchingBeans(OnBeanCondition.java:169)atorg.springframework.boot.autoconfigure.condition.OnBeanCondition.getMatchOutcome(OnBeanCondition.java:144)atorg.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)...18commonframesomittedCausedby:java.lang.NoClassDefFoundError:org/springframework/web/servlet/HandlerMappingatjava.lang.Class.getDeclaredMethods0(NativeMethod)atjava.lang.Class.privateGetDeclaredMethods(Class.java:2701)atjava.lang.Class.getDeclaredMethods(Class.java:1975)atorg.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463)...34commonframesomittedCausedby:java.lang.ClassNotFoundException:org.springframework.web.servlet.HandlerMappingatjava.net.URLClassLoader.findClass(URLClassLoader.java:387)atjava.lang.ClassLoader.loadClass(ClassLoader.java:418)atsun.misc.LauncherAppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
… 38 common frames omitted
2023-05-27 22:24:50,130 ERROR [traceId=, spanId=] 2023-05-27 22:24:50 [main] [ERROR] - Application run failed

7.2 原因

Swagger2.9.2不支持WebFlux。

7.3 方案

使用Swagger3.0.0。
访问:
http://localhost:9121/swagger-ui/index.html

6 Win11安装WSL2及Ubuntu失败

在这里插入图片描述

Installing, this may take a few minutes…
WslRegisterDistribution failed with error: 0x80370114
Error: 0x80370114 ???

方案

管理员执行终端:Win+X-》终端管理员
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

在这里插入图片描述
再次执行,安装成功。
在这里插入图片描述
查看版本:

wsl -l -v

在这里插入图片描述

5 git拥有者异常

commit时出现异常提示:
查看日志如下:
(fastapi-py310) PS D:\projects\py\python-tutorial> git log
fatal: detected dubious ownership in repository at ‘D:/projects/py/python-tutorial’
‘D:/projects/py/python-tutorial’ is owned by:
‘S-1-5-21-2994888592-1342716116-403010676-500’
but the current user is:
‘S-1-5-21-2994888592-1342716116-403010676-1001’
To add an exception for this directory, call:

    git config --global --add safe.directory D:/projects/py/python-tutorial

(fastapi-py310) PS D:\projects\py\python-tutorial>

5.1 原因

笔记本无法联网,重装win11,
更换操作系统用户,git项目没有变更用户,导致用户前后不一致。

5.2 方案

修改git项目文件夹的用户。
找到项目文件夹,依次:右键->属性->安全->高级->更改等如下图操作。
注意:我配置的账户是个人账户,不是admin,因系统的当前用户而异。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

4 Docker普通用户无权限

普通用户执行docker命令提示信息:

docker images
docker ps -a

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post “http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create?name=redis-module”: dial unix /var/run/docker.sock: connect: permission denied.

在这里插入图片描述

4.1 原因

当前用户不在Docker用户组。

4.2 方案

当前用户添加到用户组,由于只是个人操作的虚拟机,将当前用户添加到docker用户组。
$USER获取当前用户,如果是其他用户使用 $your-username。

# 添加用户组
sudo groupadd docker
# 主机用户添加到docker用户组
sudo gpasswd -a $USER docker
# 更新用户组
newgrp docker

在这里插入图片描述

3 Ubuntu22.04安装docker异常

Ubuntu22.04安装Docker出现如下异常,
因为,上次安装软件时使用了apt-get,中途中断安装。

sudo apt install docker.io

异常信息如下:
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is hWaiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1749 (unattended-upgr)
在这里插入图片描述
尝试删除文件:/var/lib/dpkg/lock-frontend
再次安装,异常信息如下:

E: Could not get lock /var/cache/apt/archives/lock. It is held by process 1749 (unattended-upgr)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to lock directory /var/cache/apt/archives/
在这里插入图片描述

再次删除相关文件:/var/cache/apt/archives/lock
即可正常安装。

在这里插入图片描述

3.1 原因

文件被中断的线程/服务占用,未被释放,无法读写。

3.2 方案

删除锁定的文件

sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/cache/apt/archives/lock

2 url内容解析

File “/app/src/utils/file_process_util.py”, line 66, in request_data_from_url
text = trafilatura.extract(source_data)
File “/usr/local/lib/python3.10/site-packages/trafilatura/core.py”, line 1050, in extract
signal(SIGALRM, timeout_handler)
File “/usr/local/lib/python3.10/signal.py”, line 56, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread of the main interpreter

2.1 方案

线上问题:FastAPI和trafilatura出现ValueError: signal only works in main thread of the main interpreter
https://blog.csdn.net/Xin_101/article/details/130313353

1 SpringBoot启动异常

14-04-2023 17:07:53 CST model_task INFO - 2023-04-14 17:07:53,379 [WARN] [main] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘solrClient’ defined in class path resource [org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.solr.client.solrj.SolrClient]: Factory method ‘solrClient’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/solr/client/solrj/impl/HttpSolrClient$ Builder (org.springframework.context.annotation.AnnotationConfigApplicationContext(org.springframework.context.support.AbstractApplicationContext.refresh:557))
14-04-2023 17:07:53 CST model_task INFO - 2023-04-14 17:07:53,416 [ERROR] [rpc-server-4-7] Error while invoking RpcHandler#receive() for one-way message. (org.apache.spark.network.server.TransportRequestHandler(org.apache.spark.network.server.TransportRequestHandler.processOneWayMessage:276))
14-04-2023 17:07:53 CST model_task INFO - org.apache.spark.SparkException: Could not find CoarseGrainedScheduler.
14-04-2023 17:07:53 CST model_task INFO - at org.apache.spark.rpc.netty.Dispatcher.postMessage(Dispatcher.scala:178)
14-04-2023 17:07:53 CST model_task INFO - at org.apache.spark.rpc.netty.Dispatcher.postOneWayMessage(Dispatcher.scala:150)
14-04-2023 17:07:53 CST model_task INFO - at org.apache.spark.rpc.netty.NettyRpcHandler.receive(NettyRpcEnv.scala:690)
14-04-2023 17:07:53 CST model_task INFO - at org.apache.spark.network.server.TransportRequestHandler.processOneWayMessage(TransportRequestHandler.java:274)
14-04-2023 17:07:53 CST model_task INFO - at org.apache.spark.network.server.TransportRequestHandler.handle(TransportRequestHandler.java:111)

1.1 原因

缺少类:

1.2 方案

启动SpringBoot是排除该类。

@SpringBootApplication(exclude = SolrAutoConfiguration.class)
public class SearchApplication extends SpringBootServletInitializer {
    
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    
    
        return builder.sources(SearchApplication.class);
    }

    public static void main(String[] args) {
    
    
        SpringApplication.run(SearchApplication.class, args);
    }
}

猜你喜欢

转载自blog.csdn.net/Xin_101/article/details/130461577
今日推荐