Tag Archives: Java exception error problem

[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

[Solved] GRPC-Server Error: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String; CLjava

Grpc server reports an error com google.common.base.Preconditions.checkArgument (ZLjava/lang/String;CLjava/lang/Object);

Problem background solution summary Lyric: I really want to take another bite, ผั๥๥๥ผั๥ณ, ผั๥ณ, ผั๥๥ณ This is the first song. It’s over. Have you guessed the title of the song?

Problem background

When working as grpc server, I can’t start it. The error report is printed as follows, but I can’t well see what’s wrong. Since grpc can be used when I test it alone, but as the project becomes more and more complex, more and more POM dependencies are introduced, so I began to find the reason from it

2022-01-25 11:01:39.896 ERROR [id-mapping-AsyncThread-1] o.s.a.i.SimpleAsyncUncaughtExceptionHandler.handleUncaughtException(SimpleAsyncUncaughtExceptionHandler.java:39): Unexpected exception occurred invoking async method: public void grpc.server.GrpcServer.start() throws java.io.IOException
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;CLjava/lang/Object;)V
	at io.grpc.Metadata$Key.validateName(Metadata.java:629)
	at io.grpc.Metadata$Key.<init>(Metadata.java:637)
	at io.grpc.Metadata$Key.<init>(Metadata.java:567)
	at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:742)
	at io.grpc.Metadata$AsciiKey.<init>(Metadata.java:737)
	at io.grpc.Metadata$Key.of(Metadata.java:593)
	at io.grpc.Metadata$Key.of(Metadata.java:589)
	at io.grpc.internal.GrpcUtil.<clinit>(GrpcUtil.java:86)
	at io.grpc.internal.AbstractServerImplBuilder.<clinit>(AbstractServerImplBuilder.java:60)
	at io.grpc.netty.shaded.io.grpc.netty.NettyServerProvider.builderForPort(NettyServerProvider.java:39)
	at io.grpc.netty.shaded.io.grpc.netty.NettyServerProvider.builderForPort(NettyServerProvider.java:24)
	at io.grpc.ServerBuilder.forPort(ServerBuilder.java:41)
	at server.Server.start(GrpcServer.java:30)
	at grpc.server.GrpcServer$$FastClassBySpringCGLIB$$be87d0e.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749)
	at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

 

Solution:

1. Analyze the imported jar package dependency and use file → setting to install Maven dependency helper dependency management

2 after installation, open the POM file, click dependency analyzer

3 select conflicts and click refresh UI to refresh. You can see that guava: version 18.0 appears, which means there is a conflict with this dependency, It’s a repeated introduction,
but the introduction of a problem is to exclude which repeated guava. This problem has been bothering me. My approach is to exclude the displayed dependencies first, and then continue to compile. If not, find other versions of guava for exclusion

4 because there is no exclusion option in Guava in right-click conflicts, Therefore, select jump to left tree to display more clearly

5 exclude 18 versions, re import

6 Click conflicts, and it is found that there is no conflict

7 at that time, the problem that the grpc server cannot be started is also solved

[Solved] IDEA Error: Error running ‘Application‘: Command line is too long

Error running ‘application’ in idea: command line is too long Shorten command line for Application or also for Spring Boot default configuration

Problem background solution 1 (current project settings) solution 2 (global settings)

Lyric: I can’t go to a good school

Command line is too long. Shorten command line for Application or also for Spring Boot default configuration)

Problem background

When idea starts the project, it suddenly reports an error

Error running 'Application':
Command line is too long.Shorten command line for Application or also for Spring Boot default configuration.

Solution:

Method 1 (current project settings)

1 click Edit configurations

in the run drop-down box of the current project. 2 Click environment, select the short command line drop-down box, select classpath file or jar manifest, and click OK to confirm

Method 2 (global setting)

1. Since scheme 1 is the current project setting and other projects are not opened, you can set the global. Click file → new projects settings → run configuration templates for new projects

2. Click springboot project. Other projects are the same as scheme 1

IDEA Error: lombok.extern.slf4j is not exist [How to Solve]

Idea reports an error Lombok extern. Slf4j is not exist no solution exists

Problem background solution summary Lyric: maltose wine

Problem background

When you start the idea project, you suddenly report an error Lombok extern. It’s been a long time since I found that the version of 4fj is compatible with Maven

Solution

1 file → setting

2 build → build tools → maven → runner, check delegate ide build and click OK