Tag Archives: maven

SpringCloud: Error creating bean with name ‘configurationPropertiesBeans‘

[problem phenomenon]

When the springcloud system is built in the idea, a red error is prompted at runtime:


org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'configurationPropertiesBeans' defined in class path resource 
[org/springframework/cloud/autoconfigure/ConfigurationPropertiesRebinderAutoConfiguration.class]: 
Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: 
Failed to introspect Class 
[org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] 
from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

......

Caused by: java.lang.IllegalStateException: 
Failed to introspect Class 
[org.springframework.cloud.context.properties.ConfigurationPropertiesBeans] 
from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]

......

Caused by: java.lang.NoClassDefFoundError: 
org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata

......

Caused by: java.lang.ClassNotFoundException: 
org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata

[reason]

This is a very common problem in the spring cloud system because the spring boot version is incompatible with the spring cloud version.

[solution]

The spring boot version and spring cloud version should be matched in strict accordance with the official version. Link to the official website:
https://spring.io/projects/spring-cloud

Different clouds need different boot versions, as shown in the figure:

Example of version change:

after version replacement, reload all Maven items, as shown in the figure:

If an error is still reported, re-execute the MVN clean package

When Jenkins deploys the project, GIT reports an error fatal: index file smaller than expected

@When Jenkins deploys the project, GIT reports an error fatal: index file smaller than expectedtoc

Recently, when learning to deploy Jenkins, microservice construction has been reporting errors:

Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress https://gitee.com/xxx +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: index file smaller than expected

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:994)
	... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

The GIT problem found on the Internet is solved as follows:

View links

Because Jenkins uses git deployed on the server to pull the remote warehouse, I handle it according to the above method and re push it. It still doesn’t work.

Later, it was found that the workspace in Jenkins should be cleaned up first, and Jenkins should be pulled from the remote warehouse again. The problem was solved. As shown in the figure:

How to Solve Nosuchmethoderror Error

1. reason
this error may be triggered when the project dependency is complex, there is a problem with the Java running environment, or there are different versions of the same type of jar package. In essence, the JVM cannot find a specific method of a class, that is, the JVM loads the wrong version of the class. To put it bluntly, the JVM can’t find the method it really wants to call! There are two main situations in which this error occurs:

Imported mismatched package version
the development environment is inconsistent with the running environment

2. solutions
check “external libraries” to see whether the error reporting method exists. If it does not exist, there must be a problem with the package. Just update the package; If it exists, it indicates that the package has been successfully introduced, but the integrated development environment may not be synchronized to. You can try to force the update. In addition, you can check whether the development environment is consistent with the running environment. If not, modify it.

3. special reminder
in case of Maven project, there are two main methods in the process of updating the package:

Go to the local Maven warehouse, delete the corresponding package, and then click refresh in “Maven project”
directly enter the command in the command line of “Maven project” to force the update
among them, method 1 is not reliable, and the operation may not be successful. The reason is unknown. Method 2 is strongly recommended. Nothing else, reliable!

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deseria

org.springframework.http.converter.HttpMessageNotReadableException:
JSON parse error: Cannot deserialize value of type `java.util.Date` from String “NULL”: not a valid representation
(error: Failed to parse Date value ‘NULL’: Unparseable date: “NULL”);
nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.util.Date` from String “NULL”: not a valid representation (error: Failed to parse Date value ‘NULL’: Unparseable date: “NULL”)
at [Source: (PushbackInputStream); line: 16, column: 14] (through reference chain: com.starsaiot.battery.entity.PledgeOrder[“payTime”])
=====================================================

I encountered this problem in a project where the front-end and back-end are separated
The front-end input data is “payTime”: “NULL”,
“tradeNum”: “null”,
“updateTime”: “2021-08-17 16:39:50”,
“updated”: “null”,
The console reports this error
====================================================
The reason for the error: the type of payTime is not correct, this capital NULL is the data I copied from the database and put in every too much attention, it should be consistent with the following null.

 

Error querying database.Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource.

Record the problems encountered in the learning process of Java mybatis framework

1. An exception occurred while building the first mybatis project:

Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: 

Error querying database. Cause: java.sql.SQLException: Error setting driver on UnpooledDataSource. 
Cause: java.lang.ClassNotFoundException: Cannot find class: com.mysql.cj.jdbc.Driver

Solution: the MySQL connector Java driver version is used incorrectly
I use MySQL version 8.0.22

import the driver of version 5.1.23, and the dependency declared in pom.xml file is

<dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.23</version>
    </dependency>

The two versions do not correspond, so the driver error cannot be found.
the solution is to download the driver of version relative to, that is, the driver of version 8.0.22. The official website address is version 8.0.22
and then change the dependency in the POM file to:

<!--MySQL-->
<dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.22</version>
    </dependency>

Another point is that the POM file should include not only driver dependencies, but also mybatis dependencies

<!--mybatis-->
<dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.4.5</version>
    </dependency>

Java.lang.stackoverflowerror error [How to Solve]

I just started learning Java. If something is wrong, please show mercy
when practicing Maven’s integrated SSM framework, a java.lang.stackoverflowerror error occurs when performing multi condition query. Generally, this error is due to the problem of dead loop or recursion, but I do not use loop and recursion. The error is shown in the figure, It calls a method of servie to find all the data in a table from mapper

examination was found to be a very low-level mistake. I injected it wrong, injected myself into the service, and then invoked my own method, resulting in an overflow error. 
after injecting mapper, it runs successfully

The project uses fastjason to report an error

The project uses fastjason to report an error

java.lang.ClassNotFoundException: com.alibaba.fastjson.JSONValidator

The error shows that the jsonvalidator class cannot be found. Open the Maven interface of idea to find the related dependencies

display the dependency of this module Alipay SDK Java. The version of fastjson under this dependency is 1.2.50

Jsonvalidator is a later version

resolvent:

Introduce a new dependency in the POM file under the root directory, using fastjson version 1.2.75

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.75</version>
</dependency>