Tag Archives: java

[Solved] Error:java: Compilation failed: internal java compiler error

1, view the project’s jdk (Ctrl+Alt+shift+S)
File ->Project Structure->Project Settings ->Project

2. view the jdk of the project (Ctrl+Alt+shift+S)
File ->Project Structure->Project Settings -> Modules -> (the name of the project needs to be modified) -> Sources ->

3. View Java configuration in idea
File ->Setting ->Build,Execution,Deployment -> Compiler -> Java Compiler

If the above three steps still fail
Clear IDEA cache Restart IDEA
File->Invalidate Caches/Restart

IDEA Compile Error: java Compilation failed internal java compiler error

idea compilation failed, reporting java: Compilation failed: internal java compiler error
Check if the local jdk version is exactly the same

    File ->Project Structure->Project Settings ->Project->Project SDKFile ->Project Structure->Project Settings->Modules->Project->Language levelFile ->Project Structure->Platform->SDKs->JDK home pathSettings->Build,Execution,Deployment->Java Compiler->Per-module butecode version

Springboot error: “errorcode 1045, state 28000” [How to Solve]

Error message:

2022-02-08 14:17:32.022  INFO 1816 --- [nio-8080-exec-3] com. alibaba. druid. pool. DruidDataSource   : {dataSource-1} inited
2022-02-08 14:17:32.110 ERROR 1816 --- [eate-1764881818] com. alibaba. druid. pool. DruidDataSource   : create connection SQLException, url: jdbc: mysql://127.0.0.1:3306/itqs?allowMultiQueries=true , errorCode 1045, state 28000

 

As shown below:

Reason: application The MySQL database user name or password in the properties file is incorrect.

Solution: change to the correct user name or password.

[Solved] AndroidStudio libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined referen

1. Error reporting:

The error of Android C + + OpenSSL link is as follows:

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigfillset'

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(armcap.o):armcap.c:function OPENSSL_cpuid_setup: error: undefined reference to 'sigdelset'

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function open_console: error: undefined reference to 'tcgetattr'

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'signal'

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'

I:/webrtc/android/openssl-1.1.1k/output-armeabi-v7a/lib/libcrypto.a(ui_openssl.o):ui_openssl.c:function read_string_inner: error: undefined reference to 'tcsetattr'

clang++: error: linker command failed with exit code 1 (use -v to see invocation)

2. Reason:

Sigdelset, sigfillset and signal cannot be found in the SDK of Android

3. Solution:

Modify the minSdkVersion of build.grandle to a version number after 21:

apply plugin: 'com.android.application'
def LIBWEBRTC_HOME_PATH = "I:/webrtc/android/webrtc_m84_20201001/webrtc_android/src/"
//def LIBWEBRTC_HOME_PATH = "I:/webrtc/android/androidnativeapi/app/webrtc/"
android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "org.webrtc.examples.androidnativeapi"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                arguments "-DLIBWEBRTC_HOME_PATH=" + LIBWEBRTC_HOME_PATH,
                        "-DANDROID_STL=c++_static"
            }
        }
        ndk {
            abiFilters  "armeabi-v7a"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    sourceSets {
        main {
            // 1. configure the root directory libs to load third-party so libraries, (it is best not to create jniLibs, in the many open source libraries may cause conflicts, not yet found)
            // 2. automatically copy the so libraries in the libs directory to the specified directory when running
            // 3. If you don't need to recompile the so you created, you can copy the so generated by (app/build/intermediates/transforms) to this directory
            jniLibs.srcDirs = ['libs']
            // If it is a single folder, you can directly configure it as follows
            // jniLibs.srcDir 'libs'
        }
    }
    buildToolsVersion '28.0.2'//ADD
}
repositories {
    flatDir{
        dirs'libs'
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.aar"])

    //implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    //implementation(name: 'libwebrtc', ext: 'aar')
    //implementation 'org.webrtc:google-webrtc:1.0.+'
}

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [hello scope], template mi

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [hello scope], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) [thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:362) [thymeleaf-spring5-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:189) [thymeleaf-spring5-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1373) [spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1118) [spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1057) [spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) [spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) [spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) [spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:626) [tomcat-embed-core-9.0.41.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) [spring-webmvc-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) [tomcat-embed-core-9.0.41.jar:4.0.FR]
at

 

Solution: The method I wrote in the controller layer was wrongly written

[Solved] write javaBean error, fastjson version 1.2.76, class org.apache.flink.table.data.binary

An exception is thrown when using the static variable Map as a return

com.alibaba.fastjson.JSONException: write javaBean error, fastjson version 1.2.76, class org.apache.flink.table.data.binary.BinaryStringData, fieldName : id, Memory segment does not represent off heap memory

The rest of the code remains unchanged, and only an empty new Map is returned. The result is normal, which proves that there is a problem with the encoding of the fields inside, so it can be re-encoded
for (Map<String, Object> map : FakerConstant.TABLE_ROW_DATA_RESULT) {
            Map<String, Object> m = new HashMap<>();
            map.forEach((key, value) -> {
                m.put(
                        // You need to re-encode it, otherwise it will report FastJson exception. write javaBean error, fastjson version 1.2.76
                        new String(key.getBytes(), StandardCharsets.UTF_8),
                        new String(String.valueOf(value).getBytes(), StandardCharsets.UTF_8)););
            });
            res.add(m);
        }

[Solved] Redis Client On Error: Error: write ECONNABORTED Config right

Solve the redis client on error: error: write econnaborted config rightwe

Problem Description:
Solution:

1. First, check whether the firewall of Linux is turned on

Turn off the firewall

[root@localhost]# systemctl stop firewalld.service

Open 6379 port

[root@localhost]# sudo firewall-cmd --zone=public --add-port=6379/tcp --permanent
success
[root@localhost]# sudo firewall-cmd --reload
success

2. Check whether the redis startup configuration is correct

Check whether redis is started

 ps -ef | grep redis

For versions above redis 3.2, Internet access is not allowed by default, and needs to be modified redis.conf configuration file

Modify peetected-mode

Modify peotected-mode yes
to: protected-mode no.
#The protected-mode parameter is used to disable access to redis from outside the network, if enabled, only the localhost ip (127.0.0.1) will be able to access Redis

Close bind 127.0.0.1

Comment out bind 127.0.0.1, or modify bind 0.0.0.0, to allow access to all ip addresses

After modifying the configuration file, remember to restart redis,

./redis-server /usr/local/redis/redis.conf

Java database Druid error: com.alibaba.druid.pool.DruidDataSource error

1. Error information

Feb 02, 2022 10:44:44 AM com.alibaba.druid.pool.DruidDataSource error
WARNING: init datasource error, url: jdbc:mysql://localhost:3306/xuesheng?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1570)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1636)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:874)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1246)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1242)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:89)
	at com.qzxiaofeng.jdbc.DruidDemo.main(DruidDemo.java:21)

Feb 02, 2022 10:44:44 AM com.alibaba.druid.pool.DruidDataSource error
WARNING: {dataSource-1} init error
java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1570)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1636)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:874)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1246)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1242)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:89)
	at com.qzxiaofeng.jdbc.DruidDemo.main(DruidDemo.java:21)

Feb 02, 2022 10:44:44 AM com.alibaba.druid.pool.DruidDataSource info
WARNING: {dataSource-1} inited
Exception in thread "main" java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1570)
	at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1636)
	at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:874)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1246)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1242)
	at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:89)
	at com.qzxiaofeng.jdbc.DruidDemo.main(DruidDemo.java:21)

II My configuration is as follows
1 Test code

public class DruidDemo {
    public static void main(String[] args) throws Exception {

        //3.Load the configuration file
        Properties prop=new Properties();
        prop.load(new FileInputStream("src/druid.properties"));
        //4. Get the connection pool object
        DataSource dataSource = DruidDataSourceFactory.createDataSource(prop);
        //5. Get the corresponding database connection
        Connection connection = dataSource.getConnection();
        System.out.println(connection);

//        System.out.println(System.getProperty("user.dir"));
    }
}

2. Configuration of guide package in maven

<!--         druid-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.12</version>
        </dependency>

3.druid.properties configuration

driverClassName=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/xuesheng?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
user=root
password=123456
# initialize the number of connections
initialSize=5
#Maximum number of connections
maxActive=10
#Maximum waiting time
maxWait=3000

3. Solution

Change the user to username in druid.properties

[Solved] Springboot Error: Error creating bean with name ‘dataSource‘ defined in class path resource

Springboot reports error creating bean with name ‘datasource’ defined in class path resource, factory method ‘datasource’ three exception; nested exception is org.springframework.boot.autoconfigure.jdbc.Datasourceproperties $datasourcebeancreationexception: failed to determine a suitabledriver class solution

Problem background solution experience Lyric: cut me apart from two spirits

Problem background:

An error is reported when connecting to MySQL:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 87 more
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

Solution:

1. It can be seen from the error report that the configuration of datasource database cannot be found. After inspection, it was forgotten in application The YML configuration file configures the database information

spring:
  datasource:
      #url: jdbc:mysql://[ip]:[port]/[name]?useSSL=false&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
    url: jdbc:mysql://localhost:3306/mysqlTest?serverTimezone=UTC&characterEncoding=UTF-8
    username: root
    password: 123456
    driver-class-name: com.mysql.cj.jdbc.Driver
  sql:
    init:
      encoding: utf-8

nacos Start Error: Error creating bean with name ‘grpcClusterServer’

Today, I installed Nacos locally and reported the error creating bean with name ‘grpcclusterserver’ at startup. When I went to search for the cause of the error, I saw that a blogger said it would be better to try several more times. I didn’t know the specific reason, so I shut down and restarted directly and started again successfully
screenshot of error reporting:

screenshot of success:

[Solved] stream Convert list to map Error: java.lang.IllegalStateException: Duplicate key

I background

In many scenarios, the data of List needs to be transformed into the key-value pairs of Map scenarios to facilitate quick query data. For example: the need to query the corresponding person name details scenario according to the work number. There are two kinds of scenarios, the first one is to query the database once by each work number, which is obviously not reasonable because it is not good for DB pressure and connection. The second will be a collection of work number (need to consider the volume of data scenarios, Oracle supports a maximum of one thousand, mysql, although no online, but consider the performance and memory consumption need to consider the upper limit recommended 1000 below), the next is the second way to expand.

Translated with www.DeepL.com/Translator (free version)

II Development practice

List<User> userList = new ArrayList<>();

userList.add(User.builder().id(123).name("TEST123").build());

userList.add(User.builder().id(1231).name("TEST1231").build());

userList.add(User.builder().id(1232).name("TEST1232").build());

userList.add(User.builder().id(1233).name("TEST1233").build());

userList.add(User.builder().id(1234).name("TEST1234").build());

1.The stream implementation was not available before Java 1.8

Map<String, Long> idNameMap = new HashMap<String, Long>();

for(User user : userList ){

     idNameMap.put(user.getName(),  user.getId());

}

return idNameMap ;

2.Java 1.8 onwards supports stream implementation

return userList.stream().collect(Collectors.toMap(User::getName, User::getId);

III Existing problems

If you use the 2.1 way, the possible problems, if there are two data with the same name in the data, it will report an error java.lang.IllegalStateException: Duplicate key.

When using stream stream, it will not overwrite the data directly like the above way, but will report an error. So it needs to be optimized as

return userList.stream().collect(Collectors.toMap(User::getName, User::getId , (entity1, entity2) -> entity1);

It can solve the problem of error reporting.