Tag Archives: springBoot

Springboot is compatible with jackson.databind and reports errors [How to Solve]

SpringBoot and jackson.databind compatibility error reporting problem

———- ——

1、SpringBoot version V2.0.0
Its dependency on jackson-databind version is V2.9.4, when reading parameters from the configuration file application.properties to assign to the bean, it keeps reporting the following error.
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.JavaType.isReferenceType()Z
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:400)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
at com.fasterxml.jackson.databind.deser.DeserializerCache.hasValueDeserializerFor(DeserializerCache.java:191)
at com.fasterxml.jackson.databind.DeserializationContext.hasValueDeserializerFor(DeserializationContext.java:422)

The problem was solved after checking that the version was incompatible and upgrading jackson-databind to V2.9.6

 

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>

Possible causes.

Dependency conflict, or wrong version of dependency

Solution.

In springboot is to use jackson to use this

Dependencies.

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>

 

Springboot startup error: could not resolve placeholder

Springboot1.5, project startup error:

Could not resolve placeholder

Obviously, the configuration file cannot be found. The directory structure of the configuration file is as follows:

It’s normal

You can load the application-dev.properties configuration file

Check the startup working directory of idea. Shit, the default is the root directory of the whole project, not the model of the startup java file of application. Modify and finish it

[Solved] Springboot Error: found character ‘@’ that cannot start any token. (Do not use @ for indentation)

Delete the spaces in POM. XML

And then suddenly, it’s good to delete the space again

On August 14, 2019, this problem occurs again:

After deleting the space, be sure to reintroduce the Maven package. This time, the package will be used well

[Solved] The updated version of springboot causes no main manifest attribute

Recently, the springboot version was upgraded to 2.1.6. Release , and the springcloud version was upgraded to Greenwich. Sr2 when pushing the remote image to Ranger, it has been unable to start. The log shows no main manifest attribute, in/APP. Jar

Packaging tools have not changed, no problem before, and then click the mouse packaging plug-in found no version number

  <plugin>
	  <groupId>org.springframework.boot</groupId>
	  <artifactId>spring-boot-maven-plugin</artifactId>
	  <!--Be sure to match the springboot version number, because the new version of springboot no longer sets the dependencies of this plugin-->
	  <version>${spring-boot.version}</version>
	  <executions>
		  <execution>
			  <goals>
			  	<goal>repackage</goal>
			  </goals>
		  </execution>
	  </executions>
  </plugin>

Add in the version number and it’s done

Gradle Packages Springboot Error: no main manifest attribute, in ./build/libs/scaffold-1.0-SNAPSHOT.jar

The reason for the error is that the build. Gradle file is missing the package plug-in for gradle

buildscript {
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.6.RELEASE")
    }
}

plugins {
    id 'java'
}


apply plugin: 'java'
apply plugin: 'org.springframework.boot'

group 'com.guanguan.docker'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE')
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

Just patch spring-boot-gradle-plugin.

Verification.

./gradlew build

$ java -jar ./build/libs/scaffold-1.0-SNAPSHOT.jar

Then you can see the program get up.

Springboot starts with @ scheduled and reports an error: no qualifying bean

 

Error:

2018-06-12 14:02:24,709 [main] DEBUG[org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor] – Could not find default TaskScheduler bean

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:374)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334)

at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.finishRegistration(ScheduledAnnotationBeanPostProcessor.java:203)

at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.onApplicationEvent(ScheduledAnnotationBeanPostProcessor.java:182)

at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.onApplicationEvent(ScheduledAnnotationBeanPostProcessor.java:87)

at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)

at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382)

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336)

at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:877)

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)

at com.richfit.ruiche.RichfitCBMRest.main(RichfitCBMRest.java:39)

2018-06-12 14:02:24,711 [main] DEBUG [org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor] – Could not find default ScheduledExecutorService bean

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [java.util.concurrent.ScheduledExecutorService] is defined

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:374)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334)

at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.finishRegistration(ScheduledAnnotationBeanPostProcessor.java:224)

at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.onApplicationEvent(ScheduledAnnotationBeanPostProcessor.java:182)

at org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor.onApplicationEvent(ScheduledAnnotationBeanPostProcessor.java:87)

at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)

at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:382)

at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:336)

at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:877)

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)

at com.richfit.ruiche.RichfitCBMRest.main(RichfitCBMRest.java:39)

Error message analysis

The error message has two characteristics

1. the error message is a debug message.

2. The project eventually started normally, and the automated tasks in the project ran normally and were not affected.

Solution 1 – This exception log level is DEBUG, which does not affect normal usage and can be set on the log4j log level

Just add this line to the configuration under log4j

log4j.logger.org.springframework.scheduling = INFO

Effects – really no debug anymore, just printed as info

2018-06-12 14:09:39,340 [main] INFO [org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor] – No TaskScheduler/ScheduledExecutorService bean found for scheduled processing

Solution 2 – Since the error reminds that there is no [TaskScheduler], just add TaskScheduler to the SpringBoot configuration class

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

@Configuration
public class WebAppConfig extends WebMvcConfigurerAdapter{    
    
	@Bean
	public TaskScheduler scheduledExecutorService() {
		ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
		scheduler.setPoolSize(8);
		scheduler.setThreadNamePrefix("scheduled-thread-");
		return scheduler;
	}

}

– what’s the matter? What’s the meaning of reporting an error?Maybe spring hopes that technicians can specify components themselves

Spring’s timed task scheduler will try to get a registered task scheduler to do task scheduling. It will try to get a registered scheduler bean through the beanfactory.getbean method. The steps are as follows:

1. Try to find a taskscheduler bean from the configuration

2. Find the scheduled executorservice bean

3. Use the default scheduler

In the first two steps, if you can’t find it, you will throw an exception in the form of debug

logger.debug(“Could not find default TaskScheduler bean”, ex);

logger.debug(“Could not find default ScheduledExecutorService bean”, ex);

Therefore, the two exceptions printed out in the log are no error messages at all, and will not affect the use of timers. They are just some information printed by spring

★ the final solution

Both solutions are OK, and my final choice is the one in solution 2

Springboot import JPA Error: a bean named ‘entityManagerFactory’ that could not be found

 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field usuarioDao in es.uc3m.tiw.Controladores.Controlador required a bean named 'entityManagerFactory' that could not be found.

Action:

Consider defining a bean named 'entityManagerFactory' in your configuration.

Because it’s a previous project, now I report an error. It’s said on the Internet to delete the package under hibernate in Maven warehouse, but it’s no use trying it; Later, I wondered if it was the version of springboot

So in the POM. XML file

The version of springboot starts from

<version>2.1.1.RELEASE</version>

Change to

<version>2.1.4.RELEASE</version>

Project ready to run

Another mistake

***************************
APPLICATION FAILED TO START
***************************

Description:

Field roleRepository in top.wujinxing.ch15jpa.controller.RoleController required a bean of type 'top.wujinxing.ch15jpa.dao.RoleRepository' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

Action:

Consider defining a bean of type 'top.wujinxing.ch15jpa.dao.RoleRepository' in your configuration.

Process finished with exit code 1

You need to add the

@ComponentScan(basePackages = "top.wujinxing.ch15jpa.dao")

Reason: Failed to determine a suitable driver class


Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
2020-03-29 15:01:42.227 ERROR 9172 — [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 1
Reason for error]:Error in data source
Check]: ①application in the url address
②Database configuration
③Introduction of dependencies in the pom file
The reason for my error is that the druid dependency is introduced incorrectly
Correct:

错误:

[Note]: druid data source has spring
At the same time, some people on the Internet tell us to comment out mybaties dependencies and add annotations to the startup class, but I didn’t follow the Internet’s instructions.
mybaties retain

Handler dispatch failed; nested exception is java.lang.StackOverflowError

Welcome to my official account, add me as a friend!

Springboot project encountered “handler dispatch failed; nested exception is java.lang.StackOverflowError ”My mistake.

To sum up:

Stackoverflowerror is usually a dead loop or loop dependent.

Caused by: java.lang.StackOverflowError
	at com.hry.seckill.service.impl.GoodsServiceImpl.getGoodsVoList(GoodsServiceImpl.java:17)
	at com.hry.seckill.service.impl.GoodsServiceImpl.getGoodsVoList(GoodsServiceImpl.java:17)
	at com.hry.seckill.service.impl.GoodsServiceImpl.getGoodsVoList(GoodsServiceImpl.java:17)
	at com.hry.seckill.service.impl.GoodsServiceImpl.getGoodsVoList(GoodsServiceImpl.java:17)
	at com.hry.seckill.service.impl.GoodsServiceImpl.getGoodsVoList(GoodsServiceImpl.java:17)
	at com.hry.seckill.service.impl.GoodsServiceImpl.getGoodsVoList(GoodsServiceImpl.java:17)

 
Then check the location of the location and find the error:

 
 

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsService goodsService;

I did not correctly refer to mapper in service, but referred to service, so I can report an error and correct it.

 

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;

Finally, restart the project.

Welcome to my official account, add me as a friend!