user7048050
user7048050

Reputation: 41

Jhipster generated code after the error, Mapper could not be found

2016-10-20 18:03:51.253 WARN 17216 --- [ restartedMain] .s.c.a.CommonAnnotationBeanPostProcessor : Invocation of destroy method failed on bean with name 'cacheConfiguration': java.lang.NullPointerException 2016-10-20 18:03:51.274 WARN 17216 --- [ restartedMain] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.annotation.ProxyCachingConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' is defined) 2016-10-20 18:03:51.749 ERROR 17216 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Field countryMapper in com.bosheng.java.service.impl.CountryServiceImpl required a bean of type 'com.bosheng.java.service.mapper.CountryMapper' that could not be found.

Action:

Consider defining a bean of type 'com.bosheng.java.service.mapper.CountryMapper' in your configuration.

Upvotes: 2

Views: 4014

Answers (5)

Ebraheem Alrabeea
Ebraheem Alrabeea

Reputation: 2250

I have tried all the above solutions and followed the jHipster IDE configuration and my problem still not fixed.

That's what solved my problem:

mvnw clean
mvnw compile

For Gradle:

gradlew clean
gradlew compileJava

then refresh the project in the IDE and run it.

Upvotes: 2

Aaron.Zhao
Aaron.Zhao

Reputation: 101

If you are using IDEA and Maven, you need to activate the IDE profile in IntelliJ. This is used for applying IDE-specific tweaks which currently only includes applying the MapStruct annotation processor.

Open the “Maven Projects” tool window (View -> Tool Windows), check the IDE maven profile to activate it

Upvotes: 7

Gemtastic
Gemtastic

Reputation: 6433

I had this issue and it was only an issue with my pom.xml. I needed to add mapstruct to the maven compiler plugin like so:

...

<properties>
    <mapstruct.version>1.1.0.Final</mapstruct.version>
    <maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
</properties>

...

<dependencies>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct-jdk8</artifactId>
        <version>${mapstruct.version}</version>
    </dependency>
</dependencies>

...

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
            <annotationProcessorPaths>
                <path>
                    <groupId>org.mapstruct</groupId>
                    <artifactId>mapstruct-processor</artifactId>
                    <version>${mapstruct.version}</version>
                </path>
            </annotationProcessorPaths>
        </configuration>
    </plugin>
</plugins>

Upvotes: 1

Felipe Balduino Cassar
Felipe Balduino Cassar

Reputation: 784

I had a similar problem, but using Maven and Eclipse. At the end I realized that I hadn't read well the bottom of the "Configuring your IDE" page from jHipster docs, which says about MapStruct, but I also had to add the target/generated-sources folder to my build path (as instructed on http://g00glen00b.be/mapstruct/ ).

Upvotes: 2

Duff
Duff

Reputation: 851

Please, next time, add the command line you use to build / launch your app and use code format, in order to have a good format for your question. ;o)

So, according to this log, I suggest you to use IDE and dev maven profil. I am quite sure you don't use it, so mapstruct have the interface for bean but not generated the implementation classes.

Upvotes: 0

Related Questions