Solution:
Remove the contents in the red box and then switch to home. After the home switch is completed, reset the JDK here
Solution:
Remove the contents in the red box and then switch to home. After the home switch is completed, reset the JDK here
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'reachIndex' method
com.xxx.controller.ReachIndex#getxxindex(Model, String)
to { [/xxindex]}: There is already 'indexController' bean method
com..controller.IndexController#getxxindex(Model, String) mapped.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1786)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
at com.xxx.Application.main(Application.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'reachIndex' method
com.xxx.controller.ReachIndex#getxxindex(Model, String)
to { [/xxindex]}: There is already 'indexController' bean method
com.xxx.controller.IndexController#getxxindex(Model, String) mapped.
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.validateMethodMapping(AbstractHandlerMethodMapping.java:665)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:631)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:328)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod(RequestMappingHandlerMapping.java:395)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.registerHandlerMethod(RequestMappingHandlerMapping.java:76)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$2(AbstractHandlerMethodMapping.java:298)
at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:296)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.processCandidateBean(AbstractHandlerMethodMapping.java:265)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:224)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:212)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:206)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1845)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1782)
... 21 common frames omitted
Question:
Mainly the controller layer appears with two same url: @RequestMapping(“/xxxx”);
Solution:
Comment out one of them, or modify the mapping address inside the brackets of one of the @RequestMapping(“/xxxx”).
Start spring cloud. A simple Eureka server service starts with an error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultValidator' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.valueextraction.ValueExtractorManager
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1699) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at com.itmuch.cloud.study.EurekaApplication.main(EurekaApplication.java:15) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.valueextraction.ValueExtractorManager
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:140) ~[hibernate-validator-6.0.11.Final.jar:6.0.11.Final]
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:38) ~[hibernate-validator-6.0.11.Final.jar:6.0.11.Final]
at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:364) ~[hibernate-validator-6.0.11.Final.jar:6.0.11.Final]
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:309) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
... 16 common frames omitted
The hibernate-validator version problem
it is found that the version relied on in my POM file is
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.11.Final</version>
</dependency>
Kick out the hibernate-validator version and re-reference it
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<exclusions>
<exclusion>
<artifactId>hibernate-validator</artifactId>
<groupId>org.hibernate.validator</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.20.Final</version>
</dependency>
</dependencies>
1. Error description
ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
What went wrong:
Execution failed for task ‘:app:externalNativeBuildDebug’.
Build command failed.
Error while executing process D:\ProgramFiles\Android\sdk\cmake\3.6.4111459\bin\cmake.exe with arguments
2. Cause of error
When developing JNI, this error occurs during compilation. It may be that the path of NDK is not set
3. Solutions
Add the path to the NDK in local.properties in the project directory
eg:
ndk.dir=D\:\\ProgramFiles\\Android\\sdk\\ndk\\21.3.6528147
Cause:
Create a maven project in idea and import pom.xml, related configuration. The following error occurred while running
****.***.***error in opening zip file
This error report occurs due to a jar version conflict in maven.
Solution:
Delete the maven local repository jar package, and then idea in the project refresh, let maven re-download dependencies. (the error reported in those lines, there is a corresponding path, you can delete it)
According to the error path, delete the corresponding jar from your computer. When you come back and refresh, it’s finished.
error at ::0 formal unbound in pointcut
This error was reported when using aop’s @before for log prenotification
Error code here
@Before(value = "webLogAspect()")
public void logBefore(JoinPoint joinPoint,Object ret) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
//在attribute中加入开始时间
request.setAttribute("time",System.currentTimeMillis());
}
Then, after I remove the second parameter, it is normal
@Before(value = "webLogAspect()")
public void logBefore(JoinPoint joinPoint) {
Explain that other operations are required when multiple parameters are used, otherwise an error will be reported
@Before(value = "webLogAspect() && args(ret)")
public void logBefore(JoinPoint joinPoint, Object ret) {
Problem-solving
Upgrade to Ubuntu 18.04. Compilation error. Make a backup.
The error message is as follows
FAILED: /bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/target/product/bullhead/obj/STATIC_LIBRARIES/libedify_intermediates/lexer.cpp bootable/recovery/edify/lexer.ll"
flex-2.5.39: loadlocale.c:130:_nl_intern_locale_data: ??'cnt < (sizeof (_nl_value_type_LC_TIME)/sizeof (_nl_value_type_LC_TIME[0]))' ???
Aborted (core dumped)
Solution:
Adding export LC_ALL=C
before compiling will solve the problem.
As long as it is recorded on the screen, it is difficult to report errors. The common causes and solutions are summarized as follows:
1. Determine the storage permission. Note that Android 10, 11, 12, etc. the storage permission policy of Android has changed. Set the output path to ensure that it is under the path with read-write permission
File file=new File(getExternalFilesDir("")+"/Ansen_");
if(!file.exists()){
file.mkdirs();
}
//Set the video output path
mMediaRecorder.setOutputFile(file.getAbsolutePath() + "/Ansen_" + curTime + ".mp4");
2. Correctly set the size of the recording screen, here note that this size is not necessarily the screen size, through the following method is not necessarily the same as the actual resolution, such as a plus phone, originally 1920 * 1080, in fact, through the following measurement results are not, this will require developers to get through the Camera.
//Set the video size
mMediaRecorder.setVideoSize(ScreenUtils.getScreenWidth(this), ScreenUtils.getScreenHeight(this));
Conventional method for obtaining the size of mobile phone (not necessarily accurate, inconsistent with the recording screen):
/**
* Get the width of the screen px
*/
public static int getScreenWidth(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(outMetrics);
return outMetrics.widthPixels;
}
/**
* Get the width of the screen px
*/
public static int getScreenHeight(Context context) {
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics outMetrics = new DisplayMetrics();
windowManager.getDefaultDisplay().getMetrics(outMetrics);
return outMetrics.heightPixels;
}
To get the resolution supported by the camera, just select a group from the following.
Camera camera = Camera.open();
Parameters parameters = camera.getParameters();
List<Size> supportedPreviewSizes = parameters.getSupportedPreviewSizes();
for (int i = 0; i < supportedPreviewSizes.size(); i++) {
supportedPreviewSizes.get(i).width;
supportedPreviewSizes.get(i).height;
}
List<Size> supportedPictureSizes = parameters.getSupportedPictureSizes();
for (int i = 0; i < supportedPictureSizes.size(); i++) {
supportedPictureSizes.get(i).widt;
supportedPictureSizes.get(i).height;
}
3. Determine the setting sequence, which will affect
setAudioSource()
setVideoSource()
setOutputFormat()
setAudioEncoder()
setVideoEncoder()
setVideoSize()
setVideoFrameRate()
setOutputFile()
setVideoEncodingBitRate()
prepare()
start()
Solution:
Check always update snapshots in idea and rebuild Maven project
Running error
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.scheduling.quartz.SchedulerAccessor.registerListeners(SchedulerAccessor.java:351)
The following method did not exist:
org.quartz.Scheduler.getListenerManager()Lorg/quartz/ListenerManager;
The method's class, org.quartz.Scheduler, is available from the following locations:
jar:file:/D:/repository/org/opensymphony/quartz/quartz/1.6.1/quartz-1.6.1.jar!/org/quartz/Scheduler.class
It was loaded from the following location:
file:/D:/repository/org/opensymphony/quartz/quartz/1.6.1/quartz-1.6.1.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.quartz.Scheduler
Analysis: it worked well before, but suddenly it didn’t work. Reading the report incorrectly may be caused by the jar package conflict of the scheduled task
1. A global check reveals that shiro-all has introduced this jar package
Solution:
When querying the dependency, I found that it is an optional part of shiro, so I exclude it directly.
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-all</artifactId>
<version>1.4.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-quartz</artifactId>
</exclusion>
</exclusions>
</dependency>
If the shiro-all package is introduced in a jar package, the following code can be placed under the parent package introduced by the project
<exclusions> <exclusion> <groupId>org.apache.shiro</groupId> <artifactId>shiro-quartz</artifactId> </exclusion> </exclusions>
Description:
When using springboot to integrate swagger2config, an error is reported. The error information is as follows:
Analysis:
I am using Springboot 2.6.3, Spring Boot 2.6.X uses PathPatternMatcher to match paths, the path matching used by Springfox referenced by Swagger is based on AntPathMatcher, so it needs to be configured.
Solution:
Add the following configuration to the YML configuration file:
spring:
mvc:
pathmatch:
matching-strategy: ANT_PATH_MATCHER
Java HotSpot ™ 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated
It may be a JDK version problem
jdk1.8 is OK
if you want to use a higher version, such as jdk11
Windows:
Modify bin\runserver.cmd
Linux:
Modify bin\runserver.sh
before modification:
set "JAVA_OPT=%JAVA_OPT% -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC"
After modification:
set "JAVA_OPT=%JAVA_OPT% -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8"