Tag Archives: java

Redis reports an error when integrating springsecurity: could not read JSON: unrecognized field “enabled”“

When springboot integrates springsecurity, an error occurs:

  By viewing the error reporting information, it is found that the errors are reported where redis is used. In the project, redis is used as a cache to store user information. Everything is normal when spring security is not integrated, but there is a problem after the integration. I checked several blogs on the Internet and found that there is a problem when redis serializes and stores user objects.

Key error messages:

Could not read JSON: Unrecognized field "enabled" (class com.xyc.community.entity.User), not marked as ignorable (11 known properties: "authorities", "status", "activationCode", "username", "createTime", "type", "id", "email", "headerUrl", "salt", "password"])
 at [Source: (byte[])"{"@class":"com.xyc.community.entity.User","id":134,"username":"www","password":"3d3aeebb9cd302ae581dfa8fedd86ceb","salt":"dfc00","email":"[email protected]","type":0,"status":1,"activationCode":null,"headerUrl":"http://images.nowcoder.com/head/134t.png","createTime":["java.util.Date",1555668837000],"enabled":true,"accountNonExpired":true,"accountNonLocked":true,"credentialsNonExpired":true}"; line: 1, column: 318] (through reference chain: com.xyc.community.entity.User["enabled"]); nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "enabled" (class com.xyc.community.entity.User), not marked as ignorable (11 known properties: "authorities", "status", "activationCode", "username", "createTime", "type", "id", "email", "headerUrl", "salt", "password"])
 at [Source: (byte[])"{"@class":"com.xyc.community.entity.User","id":134,"username":"www","password":"3d3aeebb9cd302ae581dfa8fedd86ceb","salt":"dfc00","email":"[email protected]","type":0,"status":1,"activationCode":null,"headerUrl":"http://images.nowcoder.com/head/134t.png","createTime":["java.util.Date",1555668837000],"enabled":true,"accountNonExpired":true,"accountNonLocked":true,"credentialsNonExpired":true}"; line: 1, column: 318] (through reference chain: com.xyc.community.entity.User["enabled"])

You can see that several fields are added during serialization because the userdetails interface is implemented in the user class in order to integrate springsecurity. These methods have been rewritten

  terms of settlement:

Using the @ jsonignoreproperties annotation, you can ignore these fields when the user object is serialized

Add before user class:

@JsonIgnoreProperties({"enabled","accountNonExpired", "accountNonLocked", "credentialsNonExpired", "authorities"})

Failure of spring boot configuration server port

Problem Description: do not go to the port configured by yourself after the project is started?Just go 8080

Solution 1

Please check whether there is any in the target file after packaging   Application profile

  If not, add the following code to the POM file

         <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>mapper/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

Solution 2

        Check whether the configuration file format is aligned, whether there are redundant spaces, etc

JAVA: How to Use Minio to upload pictures

In the recent project, the Minio drawing bed server is used to upload pictures. Make a record here. The environment of the project is as follows:
Nacos, gradle, springboot, mybatis, MySQL

First, you need to add Minio dependency in gradle. Version 3.0.10 is used in this project

compile 'io.minio:minio:3.0.10'

Then add the configuration class of minioutils in the project to call the service of Minio and provide the interface for calling Minio to upload pictures. All the parameters required in the project are written in the Nacos configuration center. Therefore, take the corresponding parameters from the Nacos configuration file in the annotation form of @ nacosvalue and call the interface for uploading pictures, Returns the URL of a Minio domain name/bucket name/file name stored in the bucket

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.iid.common.helper.IdHelper;
import io.minio.MinioClient;
import io.minio.errors.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.xmlpull.v1.XmlPullParserException;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

/**
 * @ClassName MinioUtils
 * @Description: TODO
 * @Author XuJianSong
 * @Date 2021-01-07
 * @Version V1.0
 **/
@Slf4j
@Component
public class MinioUtils {
    private MinioClient minioClient;
    @NacosValue(value = "${ymukj.minio.endpoint}")
    private String endPoint;
    @NacosValue(value = "${ymukj.minio.accessKey}")
    private String accessKey;
    @NacosValue(value = "${ymukj.minio.secretKey}")
    private String secretKey;
    @NacosValue(value = "${ymukj.minio.preUrl}")
    private String preUrl;

    @PostConstruct
    public void initMinioClient() {
        try {
            minioClient = new MinioClient(endPoint, accessKey, secretKey);
        } catch (InvalidEndpointException e) {
            log.error(e.getMessage(), e);
        } catch (InvalidPortException e) {
            log.error(e.getMessage(), e);
        }
    }

    public String uploadFile(String bucketName, String objName, InputStream inputStream, Long lenght, String contentType) {
        // Use putObject to upload a file to the storage bucket.
        try {
            minioClient.putObject(bucketName, objName, inputStream, lenght, contentType);
            boolean isExist = minioClient.bucketExists(bucketName);
            if (!isExist) {
                minioClient.makeBucket(bucketName);
            }
            return preUrl+"/"+objName;
        } catch (Exception e) {
            e.printStackTrace();
            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>Error:" + e);
            return null;
        }
    }
}

In Minio, there is the concept of “bucket”. The so-called bucket is the folder on the Minio drawing bed. If the bucket name passed to the parameter already exists on the drawing bed, the uploaded picture will be stored in the current bucket
if the bucket name transferred to the parameter does not exist on the drawing bed, the bucket will be created in the source code method first and then saved

As shown in the figure: the bucket in the Minio drawing bed is on the left, and the files in the bucket are on the right. Minio supports uploading all files. Video and document files are OK, but these functions are not involved in the project, which will be studied later

The next step is to write the interface for uploading pictures in the project. Because it does not involve the operation of the database, I directly wrote all the interfaces in the controller layer and did not call the method of the service layer
the controller layer interface receives the file parameters from the front end, and then processes the files according to the requirements of the parameters received by the method for uploading pictures in the minioutils configuration class, First, we can see that the upload image interface in the miniutils configuration file requires four parameters: bucket, objname, InputStream, lenght and contenttype. The four parameters are: bucket name, file name uploaded and saved to bucket, file input stream and file type. If the upload is successful, a URL will be returned. Put the URL in the browser to directly open the picture. If you need to use the picture in the project, you can directly store the URL in the database and get it from the database later

public GlobalResponse uploadPic(MultipartFile file) {
    String bucket = "pic";
    String filename = file.getOriginalFilename();
    String[] exts = filename.split("\\.");
    String ext = exts[exts.length - 1];
    String caselsh = filename.substring(0,filename.lastIndexOf("."));
    String objName = SystemHelper.now() + caselsh + "." + ext;
    log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>objName:" + objName);
    String contentType = file.getContentType();
    InputStream inputStream = null;
    Long lenght = null;
    try {
        inputStream = file.getInputStream();
        lenght = Long.valueOf(inputStream.available());
    } catch (IOException e) {
        e.printStackTrace();
    }
    String picUrl = minioUtils.uploadFile(bucket, objName, inputStream, lenght, contentType);
    log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>picUrl:" + picUrl);
    return GlobalResponse.success(picUrl);
}

Note that the file name uploaded to the bucket should not be repeated! Don’t repeat! Don’t repeat
because duplicate file names can cause a problem: for example, if you upload a picture a.png first and save it in the bucket with the name 111.png, then the Minio domain name/bucket name/111.png can directly open the picture a.png, but if you upload a picture B.png and save it to the same name 111.png, then the Minio domain name/bucket name/111.png opens the picture B.png, If the picture a.png has been stored in the database and has been used, the consequences can be imagined
therefore, the solution used in the interface is to use the form of timestamp + original file name + suffix. Because the timestamp is 13 bits and milliseconds, even if a file with the same name is uploaded, there will be no problem that the file name saved in the bucket will be repeated

That’s all for this sharing. If you have any mistakes, please correct them!

Flink Error: is not serializable. The object probably contains or references non serializable fields.

Today, a colleague suddenly reported such an error. At first, he really didn’t react. Member variables can’t be serialized….

Exception in thread "main" org.apache.flink.api.common.InvalidProgramException: [email protected] is not serializable. The object probably contains or references non serializable fields.
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:151)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:126)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:71)
	at org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.clean(StreamExecutionEnvironment.java:1821)
	at org.apache.flink.streaming.api.datastream.DataStream.clean(DataStream.java:188)
	at org.apache.flink.streaming.api.datastream.KeyedStream.process(KeyedStream.java:398)
	at org.apache.flink.streaming.api.datastream.KeyedStream.process(KeyedStream.java:374)
	at com.xintujing.flinkdemo.text.UserCount_3.main(UserCount_3.java:53)
Caused by: java.io.NotSerializableException: java.lang.ref.ReferenceQueue$Lock
	at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
	at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
	at org.apache.flink.util.InstantiationUtil.serializeObject(InstantiationUtil.java:586)
	at org.apache.flink.api.java.ClosureCleaner.clean(ClosureCleaner.java:133)
	... 11 more

When you see this error, you are in an ignorant state and cannot be serialized. What do you mean?

First, analyze the problem. He tells us that a class cannot be serialized,

What happens if a member in a class does not implement a serializable interface?A simple question about the Java serialization process. If you try to serialize an object that implements a serializable class, but the object contains a reference to a non serializable class, a non serializable exception notserializableexception will be thrown at run time,

Well, if you take an object as a member variable of another object, all member variables of the object must be serializable. If the member variables cannot be serialized, this error will be reported. So. Don’t treat non serializable things as member variables.

[Solved] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-cli) on

This problem bothered me for a while. What I want to say is that I couldn’t find the problem when deploying springboot through Maven. Therefore, after quickly arranging a springboot project, I found that the error will still be reported

So I looked at this version number and added it in and it worked
   <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.3</version>
            </plugin>
        </plugins>
    </build>

[Solved] Java.lang.IllegalStateException: getReader() has already been called for this request

For the project, it is necessary to obtain the data in the request body in the interceptor for data verification, because the @ requestbody annotation is used in the self-defined controller, resulting in an error in the project. The content of the error is: Java. Lang. IllegalStateException: getreader() has already been called for this request

After consulting the data, it is found that the getReader and getinputstream in the request are obtained by stream. After reading once, they can’t be used again. The solution is:

Step 1: define a filter in which a self-defined request is passed in. The self-defined request inherits the wrapper class httpservletrequestwrapper and rewrites the getinputstream and getReader methods
the filter code is as follows:

package com.chinastock.filter;

import com.chinastock.util.CustomHttpServletRequestWrapper;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @author zhoule
 * @description: handle request
 */
public class IMTAFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        ServletRequest requestWrapper = null;
        if(servletRequest instanceof HttpServletRequest) {
            requestWrapper = new CustomHttpServletRequestWrapper((HttpServletRequest) servletRequest);
        }
        if(requestWrapper == null) {
            filterChain.doFilter(servletRequest, servletResponse);
        } else {
            filterChain.doFilter(requestWrapper, servletResponse);
        }
    }
}

The custom request code is as follows:

import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * @author zhoule
 * @description: Custom request wrapper for processing messages in the request body
 */
public class CustomHttpServletRequestWrapper extends HttpServletRequestWrapper {
    private byte[] body;

    public CustomHttpServletRequestWrapper(HttpServletRequest request) throws IOException
    {
        super(request);

        BufferedReader reader = request.getReader();
        try (StringWriter writer = new StringWriter()) {
            int read;
            char[] buf = new char[1024 * 8];
            while ((read = reader.read(buf)) != -1) {
                writer.write(buf, 0, read);
            }
            this.body = writer.getBuffer().toString().getBytes();
        }
    }

    public String getBody(){
        return new String(body, StandardCharsets.UTF_8);
    }

    @Override
    public ServletInputStream getInputStream() throws IOException
    {
        final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body);
        return new ServletInputStream()
        {
            @Override
            public boolean isFinished() {
                return false;
            }

            @Override
            public boolean isReady() {
                return false;
            }

            @Override
            public void setReadListener(ReadListener readListener) {

            }

            public int read() throws IOException
            {
                return byteArrayInputStream.read();
            }
        };
    }

    @Override
    public BufferedReader getReader() throws IOException
    {
        return new BufferedReader(new InputStreamReader(this.getInputStream()));
    }
}

The second step is to write the interceptor of the project. Some codes of the interceptor are as follows:

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        CustomHttpServletRequestWrapper wrapper = (CustomHttpServletRequestWrapper) request;
        String body = wrapper.getBody();
        System.out.println(body);
        return true;
    }

Defining a bean of type ‘org.springframework.data.redis.core.RedisTemplate‘ in your configuration.

The spring-boot integration redis startup project reports an error with the following message:
defining a bean of type 'org.springframework.data.redis.core.RedisTemplate' in your configuration.
orConsider defining a bean of type 'org.springframework.data.redis.core.StringRedisTemplate' in your configuration.
Modify the pom file
Change the

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
        </dependency>

is changed to

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

After modification, if you want to customize redistemplate, you can refer to the following configuration


    @Bean
    public RedisTemplate<String, Object> template(RedisConnectionFactory factory) {
        // Create RedisTemplate<String, Object>object
        RedisTemplate<String, Object> template = new RedisTemplate<>();
        // Configuring the connection factory
        template.setConnectionFactory(factory);
        // Define the Jackson2JsonRedisSerializer serialization object
        Jackson2JsonRedisSerializer<Object> jacksonSeial = new Jackson2JsonRedisSerializer<>(Object.class);
        ObjectMapper om = new ObjectMapper();
        // Specify the field, field, get and set to be serialized, and the range of modifiers, ANY of which are included in private and public
        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
        // Specify the type of serialized input, the class must be non-final modified, final modified class, such as String, Integer, etc. will report an exception
        om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_ARRAY);
        jacksonSeial.setObjectMapper(om);
        StringRedisSerializer stringSerial = new StringRedisSerializer();
        // redis key Serialization method used stringSerial
        template.setKeySerializer(stringSerial);
        // redis value Serialization method usedjackson
        template.setValueSerializer(jacksonSeial);
        // redis hash key Serialization method usedstringSerial
        template.setHashKeySerializer(stringSerial);
        // redis hash value Serialization method usedjackson
        template.setHashValueSerializer(jacksonSeial);
        template.afterPropertiesSet();
        return template;
    }

[PROJECT] itdage java to get the weather and send text messages

Output JSON data:

    public class Util {
        //
        public static String getString(String url) throws IOException {
            try {
                URL u = new URL(url);

                //
                URLConnection conn = u.openConnection();
                InputStream in = conn.getInputStream();
                BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
                StringBuffer sf = new StringBuffer();
                String text = null;
                while((text = br.readLine()) != null)
                {
                    sf.append(text);
                }
                return sf.toString();
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
            return null;

        }

        public static void main(String[] args) throws IOException {
            String json = getString("https://itdage.cn/hw/weather?city=%E6%9D%AD%E5%B7%9E");
            System.out.println(json);
        }

}

Note:

   //change to
    String city = "北京" json = getString("https://itdage.cn/hw/weather?city="+URLEncoder.encode(city,"utf-8")

send message:

Test sending fixed content first


        public static void main(String[] args) throws IOException {
            String city = "北京";
            String name="b( ̄▽ ̄)d 宝";
            name = URLEncoder.encode(name,"utf-8");
     //       String json = getString("https://itdage.cn/hw/weather?city="+URLEncoder.encode(city,"utf-8"));
       //z     System.out.println(json);
  
            //String phoneNumber = "19976883561";
            String s1 = "天晴";
            s1 = URLEncoder.encode(s1,"utf-8");
                String s2 = "30-32";
                String s3 = "Relex";
            s2 = URLEncoder.encode(s2,"utf-8");
s3 = URLEncoder.encode(s3,"utf-8");
                String json2 = getString("https://itdage.cn/hw/hwSms?name="+name+"&phoneNumber="+phoneNumber+"&s1="+s1+"&s2="+s2+"&s3="+s3);
            System.out.println(json2);

        }

Output OK, SMS can be seen on the mobile phone

Use one thread to execute the task:


public class SNStask {
    private static Boolean flag;
private static Thread t1;
    public static void start(long time,String name,String phoneNumber,String city)
    {
        if(!flag)
        {

            t1 = new Thread()
            {
@Override
                public void run() {
    flag = true;
    task:
    while (flag) {
        String text = Util.send(name, phoneNumber, city);
        if (!"OK".equals(text)) {
            continue;
        }
        try {
            Thread.sleep(time);

        } catch (InterruptedException e) {
            e.printStackTrace();
            break task;
        }
    }
}
        };
            t1.start();
        }
    }
    public static  void end(){
        flag = false;
        if(t1 != null)
        {
            t1.interrupt();
        }
    }
}

Set access path:


@WebServlet("/start")
public class StartServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, UnsupportedEncodingException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/json;charset=utf-8");
        String name = request.getParameter("name");
        String phoneNumber = request.getParameter("phoneNumber");
        String city = request.getParameter("city");
        SNStask.start(time,name,phoneNumber,city);
    }

}

The problem of MAC switching JDK version and RN Android JDK version leads to compilation failure. Solve it

Make notes and notes.
refer to this
https://www.cnblogs.com/luodengxiong/p/5736806.html
How to install multi version JDK and switch under mac

Recently, I ran the old Android project and installed multiple JDK versions… Automatically installed by the as,
as a result, the Android version of the RN project reported an error. The main reason is that JDK 1.8
is required due to the problem of JDK Version (originally 1.8, openjdk 1.6 is automatically installed due to the old project…)

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper

View the current version of JDK

/usr/libexec/java_home -V

If you need to switch the JDK version, just use 1.8.
refer to this for details

Install multi version JDK and switch several methods under MAC
personal use is. Bash_ The configuration mode of profile file is also convenient for switching in the future

It should be noted that after I switch, it still doesn’t take effect, and NR still can’t run,
finally enter the path of openjdk 1.6 and delete it

Failed to read artifact descriptor for com.google.errorprone:javac:jar:9+181-r4173-1

Build failure occurs when Java Maven project is executed.

Full text of error report:

[ERROR] Failed to execute goal com.microsoft.azure:azure-webapp-maven-plugin:1.12.0:config (default-cli) on project spring-petclinic: 
Execution default-cli of goal com.microsoft.azure:azure-webapp-maven-plugin:1.12.0:config failed: Plugin com.microsoft.azure:azure-webapp-maven-plugin:1.12.0 or one of its dependencies could not be resolved: 
Failed to collect dependencies at com.microsoft.azure:azure-webapp-maven-plugin:jar:1.12.0 -> com.microsoft.azure:azure-maven-plugin-lib:jar:1.4.0 -> com.microsoft.azure:azure-tools-common:jar:0.9.0 -> com.google.errorprone:error_prone_core:jar:2.4.0 -> com.google.errorprone:error_prone_check_api:jar:2.4.0 -> com.google.errorprone:javac:jar:9+181-r4173-1: 
Failed to read artifact descriptor for com.google.errorprone:javac:jar:9+181-r4173-1: Could not transfer artifact com.google.errorprone:javac:pom:9+181-r4173-1 from/to aliyunmaven (https://maven.aliyun.com/repository/public): 
Access denied to: https://maven.aliyun.com/repository/public/com/google/errorprone/javac/9+181-r4173-1/javac-9+181-r4173-1.pom -> [Help 1]

resolvent:

reach   https://mvnrepository.com/   Find javac-9 + 181-r4173-1 in and download it   Error Prone Javac

Download in files   Javac-9 + 181-r4173-1.jar to local// Attempted to add dependency in pom.xml, invalid.

Then, execute the following command in CMD:

mvn install:install-file -DgroupId=com.google.errorprone -DartifactId=javac -Dversion=9+181-r4173-1 -Dpackaging=jar -Dfile=C:\Users\Administrator\Downloads\javac-9+181-r4173-1.jar

It can be installed normally.

reference:

https://www.freesion.com/article/74941283048/

Default constructor cannot handle exception type FileNotFoundException thrown by implicit super cons

This is a common problem when running Java:

Error message: default constructor cannot handle exception type FileNotFoundException throw by implicit super constructor. Must define an explicit constructor.

The default constructor cannot handle the exception type FileNotFoundException thrown by the implicit super constructor. You must define an explicit constructor.

Specific situation: when testing the usage method of RandomAccessFile class

A RandomAccessFile type [global variable] is declared.

import java.io.FileNotFoundException;
import java.io.RandomAccessFile;

public class MyRandomAccessFile {
    private RandomAccessFile  file = new RandomAccessFile("D:/demo/test.txt", "rw");
}

Then I searched and farted.

I checked the API of the constructor of RandomAccessFile:

public RandomAccessFile​(String name,String mode)throws FileNotFoundException
FileNotFoundException - if the mode is "r" but the given string does not denote an existing regular file, 
or if the mode begins with "rw" but the given string does not denote an existing, writable regular file and a new regular file of that name cannot be created, 
or if some other error occurs while opening or creating the file

I first checked the method of converting the implicit constructor to the display constructor, and then checked the details of this error. Mu you.

Finally, when I saw the API, I realized that was declared in the constructor of this method

In this way, we cannot directly use this method because the class name cannot declare throws, so:

1. Create a new method, take this RandomAccessFile as the return value type, and declare throws.

public RandomAccessFile createRAFByfilename(String filename,String mode)throws FileNotFoundException{
		return new RandomAccessFile(filename, mode);
}

2. Declare throws directly on the method to create the RandomAccessFile object.

public static void main() throws FileNotFoundException {
	MyRandomAccessFile mraf = new MyRandomAccessFile();
	RandomAccessFile file = mraf.createRAFByfilename("D:/demo/test.txt", "rw");
}

In short, it has nothing to do with implicit and explicit constructors.

Error creating bean with name ‘feignTargeter‘ defined in class path resource [org/springframework/cl

Specific error information:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feignTargeter' defined in class path resource [org/springframework/cloud/openfeign/FeignAutoConfiguration$DefaultFeignTargeterConfiguration.class]: Initialization of bean failed; nested exception is java.lang.IllegalAccessError: class org.springframework.cloud.openfeign.$Proxy207 cannot access its superinterface org.springframework.cloud.openfeign.Targeter
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602)
	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.AbstractBeanFactory$$Lambda$148/267257399.getObject(Unknown Source)
	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.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
	at com.ruoyi.RuoYiApplication.main(RuoYiApplication.java:21)
	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:497)
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.IllegalAccessError: class org.springframework.cloud.openfeign.$Proxy207 cannot access its superinterface org.springframework.cloud.openfeign.Targeter
	at java.lang.reflect.Proxy.defineClass0(Native Method)
	at java.lang.reflect.Proxy.access$300(Proxy.java:228)
	at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:642)
	at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557)
	at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230)
	at java.lang.reflect.WeakCache.get(WeakCache.java:127)
	at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
	at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
	at com.alibaba.cloud.dubbo.openfeign.TargeterBeanPostProcessor.postProcessAfterInitialization(TargeterBeanPostProcessor.java:75)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:430)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1798)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
	... 21 common frames omitted

Analysis reason:

First of all, the project does not configure openfeign, but uses Dubbo, but why report the error of openfeign?Secondly, during initialization   There is an error in the configuration class of openfeign. It can be seen from this that the construction must be started by default. Now that you know the direction, go to see if there are openfeign packages in the imported packages, as follows:   Really, would it be good to remove the openfeign package?It’s OK to try. The problem is solved

  terms of settlement:

Exclude the package of openfeign. Note here that the spring cloud openfeign core package or the automatic loading of openfeign configuration in the startup class are excluded, as follows:

@SpringBootApplication(exclude = { FeignAutoConfiguration.class })