Description: I am using MongoDB and it keeps asking for a datasource. I have excluded the following:
exclude=DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class,
HibernateJpaAutoConfiguration.class,
JpaRepositoriesAutoConfiguration.class})
error:
Error starting ApplicationContext. To display the conditions report re-run
your application with 'debug' enabled.
2018-10-29 11:03:25.968 ERROR 4676 --- [ restartedMain]
o.s.b.d.LoggingFailureAnalysisReporter :
Description:
***************************
APPLICATION FAILED TO START
***************************
Parameter 1 of method batchConfigurer in org.springframework.boot.autoconfigure.batch.BatchConfigurerConfiguration$JdbcBatchConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
- Bean method 'dataSource' not loaded because #ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because #ConditionalOnClass did not find required class 'javax.transaction.TransactionManager'
Action:
Consider revisiting the entries above or defining a bean of type 'javax.sql.DataSource' in your configuration.
Spring Boot is intended for building production grade applications. When it is used to build a Spring Batch application, it requires a data source to persist Spring Batch meta-data (See BATCH-2704).
But you can always use either:
an embedded datasource supported by Spring Boot (H2, HSQL or Derby) by just adding it to the classpath. This data source will be picked up automatically by Spring Batch
or provide a custom BatchConfigurer and use the MapJobRepository (See here)
Hope this helps.
Related
I´m working on this Vaadin Tutorial series.
https://www.youtube.com/watch?v=k-DxZ1reIdM&list=PLcRrh9hGNallPtT2VbUAsrWqvkQ-XE22h&index=11
Text Version: https://vaadin.com/learn/tutorials/modern-web-apps-with-spring-boot-and-vaadin/vaadin-form-data-binding-and-validation?
I´m trying to use Binding but I get the following error in my Terminal:
2020-11-22 09:11:11.012 INFO 38103 --- [nio-8080-exec-2] c.vaadin.flow.spring.SpringInstantiator : The number of beans implementing 'I18NProvider' is 0. Cannot use Spring beans for I18N, falling back to the default behavior
2020-11-22 09:11:11.373 INFO 38103 --- [nio-8080-exec-2] com.vaadin.validator.BeanValidator : A JSR-303 bean validation implementation not found on the classpath or could not be initialized. BeanValidator cannot be used.
more below the next:
Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
How do I add a Bean Validation provider? I´m working with vaadin as a maven project same as in the tutorial.
Solved by adding the following dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Although the spring-property allow-bean-definition-overriding: true is enabled in the main application.yml, I am getting an Exception. Any clue why?
Application Start
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'httpSessionManager', defined in class path resource [...], could not be registered. A bean with that name has already been defined in URL [...HttpSessionManager.class] and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
Test Start
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'metaDataSourceAdvisor' could not be registered. A bean with that name has already been defined and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
If you look at the error message, it says:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true.
Make sure your allow-bean-definition-overriding property is under the spring.main element.
When I run spring boot I get the following error. I have replaced sensitive parts with '...' as the problem should be clear anyway. This error happened without me changing any of the code in the class that is causing the error.
Description:
The bean '...', defined in class path resource [....class], could not
be registered. A bean with that name has already been defined in URL
[jar:file:/C:/m2/repository/.../0-SNAPSHOT/...-0-SNAPSHOT.jar!/...class]
and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting
spring.main.allow-bean-definition-overriding=true
I'm upgrading my application to Spring 2.1.0 and one of the new things I was trying to use is Hibernate asynchronously bootstrap.
But when I'm adding a flag spring.data.jpa.repositories.bootstrap-mode=deferred to configuration then application throws error during startup:
Parameter 0 of method entityManagerFactory in
org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration
required a single bean, but 2 were found:
- [ ] - applicationTaskExecutor: defined by method 'applicationTaskExecutor' in class path resource
[org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.class]
- taskScheduler: defined by method 'taskScheduler' in class path resource
[org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.class]
Looks like Spring have trouble with finding unique AsyncTaskExecutor bean but both beans are coming from auto configuration.
To make it work I excluded TaskExecutionAutoConfiguration because right now I'm not using it but I don't really like this approach:
#SpringBootApplication(exclude = {TaskExecutionAutoConfiguration.class})
#EnableScheduling
class MyApp {}
Any ideas how to fix it properly? Seems to me like a bug in spring boot.
I have working Spring WEB MVC application. I need to add Hibernate persistence layer, so I downloaded Spring Pet Clinic application from Github:
http://spring.io/blog/2013/03/21/spring-petclinic-is-on-github
Only changing jars to the set of jars from the Petclinic application (Spring version 4.0.1) results in the following error
12:38:54.039 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating shared instance of singleton bean 'viewResolver'
12:38:54.039 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Creating instance of bean 'viewResolver'
12:38:54.061 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.needsRefresh(Lorg/springframework/beans/factory/annotation/InjectionMetadata;Ljava/lang/Class;)Z
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:383) ~[spring-orm-4.0.1.RELEASE.jar:4.0.1.RELEASE]
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:332) ~[spring-orm-4.0.1.RELEASE.jar:4.0.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:844) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
It seems there is a conflict of Spring modules' versions.
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:332) ~[spring-orm-4.0.1.RELEASE.jar:4.0.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:844) ~[spring-beans-3.2.0.RELEASE.jar:3.2.0.RELEASE]
Make sure all your Spring dependencies have the same version.