Category Archives: JAVA

[Solved]Org.springframework.beans.factory.nosuchbeandefinitionexception error reported

Problems:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.pri.dao.UserDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Problem Description:
No match to com.pri.dao.UserDao
Error code:

14-Aug-2021 09:57:18.405 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
14-Aug-2021 09:57:18.445 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
14-Aug-2021 09:57:20.787 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4861)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1730)
	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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:484)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:433)
	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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
	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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
	... 62 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1717)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1273)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
	... 75 more

14-Aug-2021 09:57:20.797 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext

Solution:
first, check whether the Dao layer (mapper layer) has the annotation @ repository. Only when this annotation is added can this class be loaded during spring initialization.
Second, check whether the annotation is scanned in the spring configuration file. Note that the mappercannerconfigurer should be used to scan the interface of Dao layer

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.pri.dao"></property>
</bean>

instead of

<context:component-scan base-package="com.pri.dao"></context:component-scan>

This tag scans the basic components and the other three components @service @component @controller
the author made this mistake and found it after looking for a long time
so we must pay attention to the details and pay attention to the details
If an error is reported, you should analyze it yourself first. For example, if you can’t find the corresponding userdao and have comments on this class, you can only analyze the problem in the spring.xml configuration file and the scanning package
I hope I can help you!!!

Error: char cannot be dereferenced [How to Solve]

#Error reported: char cannot be dereferenced

##1. Error code

while(s.charAt(i).equals(" ")){
            i++;
        }

S is a string
## error reason
java: cannot dereference char
char is a basic data type and already a value. Here, the comparison value can be directly used = =.

##Solution 1
but the comparison here is “” (string space)
you can’t directly use the = = symbol
so replace charat() with substring()
substring() returns a string, so you can use equals()

while(s.substring(i,i+1).equals(" ")){
            i++;
        }

So the problem has been solved

##Solution 2
we can also compare it with ” (character space)
you can directly use the equal sign

while(s.charAt(i)==' '){
            i++;
        }

Doris streamload task reported an error connection reset [How to Solve]

Background

The spark program scans a hive table (size 3-7g), and then submits the streamload task of HTTP protocol to the Doris cluster. After the Doris cluster is upgraded from 0.13.15 to 0.14.12, the Spark Program suddenly reports an error streamload, and a connection reset occurs

analysis

enable_ http_ server_ V2
this parameter can be viewed by referring to the Fe Chinese configuration. It is used to determine whether to open a new style interface for the Doris interface, but in fact it has more than that. Please continue

New and old versions for Enable_ http_ server_ The default value of V2 parameter is different

In 0.13.15, the default value is false, that is, the default interface is the style of the old version, and the UI is older.

0.14.12 on the contrary, the default value is true, that is, the default interface opens a new style and new UI interface, but there will be problems at the same time
according to the analysis of the source code (palofe. Java), HTTP V2 does not limit the file size uploaded by HTTP, so the default value in springboot will be used to limit it, and the problem of connection reset will appear in the appearance.

Solution:

Method 1: close this parameter and the task can run normally

Method 2: I originally wanted to fix this problem. After looking at the community, I found that a doris-6013 was just merged two days ago, which is exactly the problem. I need to make a patch. However, note that there is a problem with this PR, and the unit is wrong. I need to make a patch together with doris-6070 to fix it.
these two PR mainly add two parameters to httpv2 in the new version of Doris

spring.servlet.multipart.max-file-size=100M
spring.servlet.multipart.max-request-size=100MB
max-file-size is the individual file size
max-request-size is to set the total uploaded data size

If you want to not limit the size of file upload, set both values to – 1. I didn’t test this – 1, but it should work. I will comment on this blog after I test it or confirm with the proposer of PR

Key supplement

After testing, it is found that the above two parameters have no effect. Refer to the community issue-6149
this patch to fix this problem

Doris Error: there is no scanNode Backend [How to Solve]

Background

No. 3.8 on the business development side responded that sparkstreaming lost, scanned the Doris table (query SQL) and reported an error

Caused by: org.apache.spark.SparkException: Job aborted due to stage failure: Task 7 in stage 0.0 failed 4 times, most recent failure: Lost task 7.3 in stage 0.0 (TID 20, hd012.corp.yodao.com, executor 7): com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: errCode = 2, 
detailMessage = there is no scanNode Backend. [126101: in black list(Ocurrs time out with specfied time 10000 MICROSECONDS), 14587381: in black list(Ocurrs time out with specfied time 10000 MICROSECONDS), 213814: in black list(Ocurrs time out with specfied time 10000 MICROSECONDS)]

Error:
detailMessage = there is no scanNode Backend. [126101: in black list(Ocurrs time out with specfied time 10000 MICROSECONDS), 14587381: in black list(Ocurrs time out with specfied time 10000 MICROSECONDS), 213814: in black list(Ocurrs time out with specfied time 10000 MICROSECONDS)]
Source Code Analysis

//Blacklisted objects
private static Map<Long, Pair<Integer, String>> blacklistBackends = Maps.newConcurrentMap();

//The task execution process requires getHost, and the return value is the TNetworkAddress object
public static TNetworkAddress getHost(long backendId,
                                      List<TScanRangeLocation> locations,
                                      ImmutableMap<Long, Backend> backends,
                                      Reference<Long> backendIdRef)

//Get the backend object by backendId in the getHost() method
Backend backend = backends.get(backendId);



// determine if the backend object is available
//return the TNetworkAddress object if it is available
//If it's not available, it iterate through the locations object to find a candidate backend object
//If the backend just unavailable is the same as the candidate backend object id, then continue
//If not, determine whether it is available, available then return to change the candidate be's TNetworkAddress
//If not available, continue to change the next candidate be


if (isAvailable(backend)) {
    backendIdRef.setRef(backendId);
    return new TNetworkAddress(backend.getHost(), backend.getBePort());
}  else {
    for (TScanRangeLocation location : locations) {
        if (location.backend_id == backendId) {
            continue;
        }
        // choose the first alive backend(in analysis stage, the locations are random)
        Backend candidateBackend = backends.get(location.backend_id);
        if (isAvailable(candidateBackend)) {
            backendIdRef.setRef(location.backend_id);
            return new TNetworkAddress(candidateBackend.getHost(), candidateBackend.getBePort());
        }
    }
}

public static boolean isAvailable(Backend backend) {
    return (backend != null && backend.isAlive() && !blacklistBackends.containsKey(backend.getId()));
}


//If a be is not returned until the end, the cause of the exception is returned
// no backend returned
throw new UserException("there is no scanNode Backend. " +
        getBackendErrorMsg(locations.stream().map(l -> l.backend_id).collect(Collectors.toList()),
                backends, locations.size()));


// get the reason why backends can not be chosen.
private static String getBackendErrorMsg(List<Long> backendIds, ImmutableMap<Long, Backend> backends, int limit) {
    List<String> res = Lists.newArrayList();
    for (int i = 0; i < backendIds.size() && i < limit; i++) {
        long beId = backendIds.get(i);
        Backend be = backends.get(beId);
        if (be == null) {
            res.add(beId + ": not exist");
        } else if (!be.isAlive()) {
            res.add(beId + ": not alive");
        } else if (blacklistBackends.containsKey(beId)) {
            Pair<Integer, String> pair = blacklistBackends.get(beId);
            res.add(beId + ": in black list(" + (pair == null ?"unknown" : pair.second) + ")");
        } else {
            res.add(beId + ": unknown");
        }
    }
    return res.toString();
}


//blacklistBackends object's put
public static void addToBlacklist(Long backendID, String reason) {
    if (backendID == null) {
        return;
    }

    blacklistBackends.put(backendID, Pair.create(FeConstants.heartbeat_interval_second + 1, reason));
    LOG.warn("add backend {} to black list. reason: {}", backendID, reason);
}


public static void addToBlacklist(Long backendID, String reason) {
    if (backendID == null) {
        return;
    }

    blacklistBackends.put(backendID, Pair.create(FeConstants.heartbeat_interval_second + 1, reason));
    LOG.warn("add backend {} to black list. reason: {}", backendID, reason);
}

Cause analysis

According to the task error
detailmessage = there is no scannode backend. [126101: in black list (ocurrs time out with specified time 10000 microseconds), 14587381: in black list (ocurrs time out with specified time 10000 microseconds), 213814: in black list (ocurrs time out with specified time 10000 microseconds)]
analysis, be ID is 126101 The reason why nodes 14587381 and 213814 are in the blacklist may be that ocurrs time out with specified time 10000 microseconds
then it is likely that the three bes on March 8 hung up at that time
according to point 7 of the previous experience of community students
it can be inferred that the be hung up because of improper tasks or configurations

Broker or other tasks overwhelm the be service_ broker_ concurrencymax_ bytes_ per_ broker_ scanner

The specific error was reported because the problem occurred on March 8. Today, more than 20 days have passed. During this period, it has experienced Doris cluster expansion, node rearrangement and other operation and maintenance work. Logs and many backups cannot be recovered. It can only be inferred from ocurrs time out with specified time 10000 microseconds that the be may have hung up at that time, Then our services will be mounted on the supervisor, so they will start automatically (the node service is not available before) ‘s Prometheus rules & amp; Alertmanager alarm)
if the same problem occurs again in the future, continue to improve this article

Solutions

Prometheus rules & amp; amp; amp; amp; nbsp; with be node service unavailable ; Alertmanager alarm
adjust the configuration in fe.conf
configure the spark task and broker task during execution
there is no substantive solution for the time being. If the problem reappears, continue to track and supplement solutions

Spring interdependence error: beancurrentyincreationexception unsatisfieddependencyexception

The project will generally start with an error reporting a certain bean loading error with the following key information.
org.springframework.beans.factory.UnsatisfiedDependencyException:Error creating bean with name ‘resUseTimeConfigController’: Unsatisfied dependency expressed through field ‘resUseTimeConfigService’; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name ‘resUseTimeConfigServiceImpl’: Bean with name ‘resUseTimeConfigServiceImpl’ has been injected into other beans [resUseTimeConfigSupport] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching – consider using ‘getBeanNamesOfType’ with the ‘allowEagerInit’ flag turned off, for example.

The main reason is that the two beans depend on each other, the simplest solution is to add the @Lazy annotation, and then add the annotation under the @Autowired of the two classes.

 

//ClassB class is dependent on ClassA

@Autowired     

@Lazy//Annotate     

private ClassA classA; 


//ClassA class is dependent on ClassB

@Autowired     

@Lazy//Annotate    

private ClassB classB; 

Feign Error: Load balancer does not have available server for client:XXX

Feign reports an error: com.netflix.client.clientexception: load balancer does not have available server for client: XXX

The first step is to check whether the name of the service called by feign is correct. Of course, this is a common way. Only when you find that the name is right can you search on the Internet. My problem is that the original call was good. As a result, the versions of springcloud and spring boot were changed to a lower level, but they couldn’t be adjusted. The service name was not changed. So I found that there was a horizontal bar on my service name. Once the horizontal bar was removed, it passed and I was drunk. So I specially wrote an example. It was really the reason for the horizontal bar

com.netflix.client.ClientException: Load balancer does not have available server for client: server-1

Summary: do not add any symbols to the service name. The lower version is incompatible, such as 2.2.6.release hoxton.sr3 I use, and the higher version is OK

[Solved] Invalid Gradle JDK configuration found. Open Gradle Settings Change JDK location

The project was fine before it was opened for a period of time, and then an error was suddenly reported after it was opened. After understanding it, it is found that deleting the gradle.xml file in the. Idea file and then rebuilding it can be generated automatically;

After comparing the previous documents, it is found that a label is missing in the document:

<option name="gradleJvm" value="11" />

The value values of different JDK versions are different, so to be on the safe side, do not modify or add the values inside. Just delete the file and regenerate it;

Java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver [How to Solve]

Java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver error reporting solution

Error report description problem description cause analysis solution operation results

Error reporting description

java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver reports an error


Problem description

when learning the contents of Java database, because the old version of teaching materials are used, and the Java version has been updated and some functions have been deleted, an error message prompted by java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver appears when reading the database: 

try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch (ClassNotFoundException e) {
            System.out.println(e);
        }

Error message: java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver


Cause analysis

since JDK1.8, the JDBC ODBC bridge has been deleted, so the ODBC driver cannot be used </ font>


Solution

 

    1. Step 1: install the old version of JDK. I install the download link of version 1.7 here: just click the next step for the jdk1.7 installation step. Step 2: change the Java environment

 

    1. friends using eclipse can refer to this blog:

 

    1. java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcodbcdriver solution 2.1 I use the integrated development environment of idea, The method is as follows:

 

    1. in file – project structure

    1. in project settings, select the JDK version downloaded for you by project SDK (here is 1.7)

 

    1. and click apply to run


Operation results

run smoothly ^ ^

Nacos boot error, unable to find Java_HOME [How to Solve]

Environment: centos7.3, JDK 8, Nacos 2.0.3.

Use the systemctl start Nacos command to start and report an error. The error information is as follows.

Use the java - version command to check that the Java environment variable is effective. You can use the Java command to eliminate the problem of environment variable configuration.

The problem should be in the Nacos startup script. The specific configuration file is shown in the figure below.

The configuration in the red box is a new line I added, that is, I manually specified the JDK used by Nacos to run, and the original detection Java of Nacos_ The configuration of home cannot get Java correctly_Home information, so it’s good to specify it manually. Add Java in the startup. Sh file_ Change the home variable to your local JDK installation location, then save and exit, and restart the Nacos service.

Use the systemctl start Nacos command to restart the service successfully. Use the systemctl status Nacos command to check that Nacos is running normally. The problem is solved.

Error in intellicode extension of vscode [Solved]

after vscode upgrade, open the java file, and vscode pops up:

Sorry, there was a problem activating IntelliCode support for Java. For more information
Please see the "Language Support for Java" and "VS IntelliCode" output windows

the reason is that the language support for Java by red hat extension version above 0.65 only supports versions above java11, so it will revert to versions below 0.64.1

Springboot Files Upload Limit Error: The field file exceeds its maximum permitted size of 1048576 bytes

An error is reported in file upload, and the interface breakpoint does not go because of the default limit of Tomcat

Spring Boot:The field file exceeds its maximum permitted size of 1048576 bytes.

The configuration file can be changed. I use YML configuration

spring:
  servlet:
    multipart:
      max-file-size: 50MB
      max-request-size: 100MB

Please like it and form good habits!

Please leave a message for questions, communication and encouragement!

The online method is not easy to use, as follows

Solution 1: Prompt for expired methods!!!

Add the following code to the startup class.

@Bean
public MultipartConfigElement multipartConfigElement() {
  MultipartConfigFactory factory = new MultipartConfigFactory();
  // single file maximum
  factory.setMaxFileSize("10240KB"); // KB,MB
  // Set the total upload data size
  factory.setMaxRequestSize("102400KB");
  return factory.createMultipartConfig();

}

Solution 2: red line burst, prompt too long

Depending on the version of spring boot, add different configurations to the application file

Spring Boot 1.3 or earlier, the configuration:

  multipart.maxFileSize = 100Mb

multipart.maxRequestSize=150Mb

Spring Boot 1.4 or later, the configuration:

  spring.http.multipart.maxFileSize = 100Mb
  spring.http.multipart.maxRequestSize = 150Mb


Spring Boot 2.0 or later: Mb change to MB

spring.servlet.multipart.max-file-size = 100MB
spring.servlet.multipart.max-request-size = 150MB

Upload file error analysis standardmultiparthttpservletrequest

controller

/**
 * MultipartFile Automatic encapsulation of uploaded files
 * @param email
 * @param username
 * @param headerImg
 * @param photos
 * @return
 */
@PostMapping("/upload")
public String upload(@RequestParam("email") String email,
                     @RequestParam("username") String username,
                     @RequestPart("headerImg") MultipartFile headerImg,
                     @RequestPart("photos") MultipartFile[] photos) throws IOException {

    log.info("Upload the message:email={},username={},headerImg={},photos={}",
            email,username,headerImg.getSize(),photos.length);

    if(!headerImg.isEmpty()){
        String originalFilename = headerImg.getOriginalFilename();
        headerImg.transferTo(new File("D:\\cache\\"+originalFilename));
    }

    if(photos.length > 0){
        for (MultipartFile photo : photos) {
            if(!photo.isEmpty()){
                String originalFilename = photo.getOriginalFilename();
                photo.transferTo(new File("D:\\cache\\1"+originalFilename));
            }
        }
    }


    return "main";
}

Common errors:

New file (“D: \ cache \ 1” + originalfilename “), there is no duplicate disk file name

Debug the debug mode and enter the transferto method. It is found that the source code is to judge whether the file exists

debug mode evaluate expression. Open the expression debugging window and see the error