UnsatisfiedDependencyException for mapper class - spring

I have created jhipster application. when I start the application I get this error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'categoryServiceImpl' defined in file [/server_2/target/classes/com/test/test/service/impl/CategoryServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.test.test.service.mapper.CategoryMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
can you help me please?

CategoryMapperImpl is generated at build time by mapstruct annotation processor from CategoryMapper interface that was generated by JHipster when importing your JDL file, make sure you have run mvnw or gradlew to generate it before starting your app.
See official doc about using DTOs: https://www.jhipster.tech/using-dtos/

Related

I just Upgrade Spring boot 2.7.4 to 3.0.0 but then some packages(jasypt, reactive-mongo) doesn't work

After change to Spring boot 3.0.0
id 'org.springframework.boot' version '3.0.0'
Error message below was occured by jasypt didn't work, so can't decrypt the encrpyted string in application.yml
Ex)
data:
mongodb:
uri: ENC(/XyOV0SVXea4LMvYgQlJpEY8a~~)
Caused by: java.lang.IllegalArgumentException: The connection string is invalid. Connection strings must start with either 'mongodb://' or 'mongodb+srv://
at com.mongodb.ConnectionString.<init>(ConnectionString.java:303) ~[mongodb-driver-core-4.8.0.jar:?]
Is there any solutions for this? good package for encrypt properties or succesfully load jasypt
PS) There is the other problem for but maybe after jasypt works well it works fine, I guess
Error creating bean with name 'reactiveMongoTemplate' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'reactiveMongoTemplate' parameter 0: Error creating bean with name 'reactiveMongoDatabaseFactory' defined in class path resource
I tried to find other package or solve the jasypt but there is no solution for this (caused by spring boot 3.0.0)

javax.enterprise.inject.UnsatisfiedResolutionException:Unsatisfied dependency for type com.test.model.TestService and qualifiers [#Default] in Quarkus

I have created Quarkus project and added a SpringBoot project dependency in build.gradle file, dependency downloaded successfully.
Now when I am trying to inject a class which is available in dependancy, the build is getting failed.
Note: The Class which I am trying to inject does not have #ApplicationScope annotation.
getting below error:
Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type com.test.model.TestService and qualifiers [#Default]
Look here:
https://quarkus.io/guides/cdi-reference
See the section 1 in the document above about creating the bean archive.
What worked for me is adding references to the dependencies in my application.properties.
quarkus.index-dependency.[name].group-id=[group]
quarkus.index-dependency.[name].artifact-id=[artifact]
For instance, in my project I injected some OpenTracing beans, ended up with:
quarkus.index-dependency.opentracing.group-id=io.opentracing
quarkus.index-dependency.opentracing.artifact-id=opentracing-api

Integrate Liquibase Groovy DSL in Spring Boot

Trying to integrate like this:
build.gradle
dependencies {
implementation 'org.liquibase:liquibase-core'
implementation 'org.liquibase:liquibase-groovy-dsl:2.1.1'
runtimeOnly 'com.h2database:h2'
runtime 'org.liquibase:liquibase-core'
runtime 'org.liquibase:liquibase-groovy-dsl:2.1.1'
}
In Spring Boot application.properties
spring.liquibase.changeLog=classpath:db/changelog/changeset0002.groovy
Have a corresponding changeset0002.groovy file under src/main/resources/db/changelog.
While doing gradle bootRun, getting the following exception:
Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
It works. In my application.properties file, with the following setting, I got it working:
spring.liquibase.change-log=classpath:META-INF/scripts/changeset0001.groovy
where the directories META-INF/scripts exist under src/main/resources of my Gradle project structure and changeset0001.groovy is a usual Groovy DSL file.

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchConfiguration'

I have created a maven module for implementing spring batch in our project. My aim is to export data from database table to CSV file (basing on a repository implemented in another maven module).
In my Spring boot main class I have the following:
#SpringBootApplication(scanBasePackages = {"com.test"})
#ComponentScan({"com.test"})
public class MainBatchApplication {
public static void main(String args []){
SpringApplication.run(MainBatchApplication.class,args);
}
}
The package com.test is the path of our implemented UserRepository I want to use to get all users from database.
Once I inject the UserRepository in my Spring Batch created maven module and once I run the spring boot app. I got the following error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchConfiguration': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.test.repositories.UserRepository.getFilteredByMonth(java.lang.String,java.util.Date,java.util.Date)!
The module where com.test if included in my batch maven module as dependency (pom.xml)
You need to define configuration somewhere in your project with:
#Configuration
#EnableBatchProcessing
public class BatchConfiguration {
....
}
Then you would be able to inject your Repository here for writers.
It would need some more bean definition. See: https://spring.io/guides/gs/batch-processing/ for examples

Issue with maven + surefire-plugin and Spring #Autowired

I have been breaking my head in getting Spring #Autowired to work inside maven tests. When I run the JUnit tests inside IntellJ (did not try Eclipse) it works. But when I run mvn clean install, the JUnit tests fail with the following error
testApp(com.sample.spring.AppTest): Error creating bean with name 'com.sample.spring.AppTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sample.spring.AppB com.sample.spring.AppTest.appB; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.sample.spring.AppB] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
I have created a self contained sample project that exhibits this behaviour consistently. I am using Spring 3.1.1. I am sure someone faced the same issue and cracked it. Looking for some pointers regarding this issue.
This is a build path issue:
Working in eclipse I changed your ContextConfiguration to :
#ContextConfiguration(locations = "classpath:applicationContext.xml")
and it runs both with standard eclipse runner and maven(maven test or maven install).
Make sure you have:
src/main/java
src/test/java and
src/test/resources
declared as source folders in your buildpath

Resources