Jhipster生成错误后的代码,无法找到Mapper

时间:2016-10-21 02:45:52

标签: jhipster mapper

2016-10-20 18:03:51.253 WARN 17216 --- [restartedMain] .s.c.a.CommonAnnotationBeanPostProcessor:对名称为' cacheConfiguration':java.lang.NullPointerException的bean调用destroy方法失败 2016-10-20 18:03:51.274 WARN 17216 --- [restartedMain] osboot.SpringApplication:错误处理失败(错误创建bean名称' delegatingApplicationListener'在类路径资源中定义[org / springframework / security / config / annotation / web / configuration / WebSecurityConfiguration.class]:bean实例化之前的BeanPostProcessor失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为' org.springframework.cache的bean时出错。 annotation.ProxyCachingConfiguration&#39 ;: bean的初始化失败;嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有名为&org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry'的bean被定义) 2016-10-20 18:03:51.749 ERROR 17216 --- [restartedMain] o.s.b.d.LoggingFailureAnalysisReporter:

申请失败

说明

com.bosheng.java.service.impl.CountryServiceImpl中的字段countryMapper需要一个类型为' com.bosheng.java.service.mapper.CountryMapper'的bean。无法找到。

动作:

考虑定义一个类型为' com.bosheng.java.service.mapper.CountryMapper'的bean。在你的配置中。

5 个答案:

答案 0 :(得分:5)

如果您使用的是IDEA和Maven,则需要在IntelliJ中激活IDE配置文件。这用于应用特定于IDE的调整,目前仅包括应用MapStruct注释处理器。

打开“Maven Projects”工具窗口(View - > Tool Windows),检查IDE maven配置文件以激活它

答案 1 :(得分:2)

我遇到了类似的问题,但是使用了Maven和Eclipse。最后,我意识到我没有很好地阅读"配置你的IDE"来自jHipster docs的页面,其中提到了MapStruct,但我还必须将 target / generated-sources 文件夹添加到我的构建路径中(按照http://g00glen00b.be/mapstruct/的说明)。

答案 2 :(得分:2)

我已经尝试了所有上述解决方案,并遵循了jHipster IDE的配置,但问题仍然没有解决。

这就是解决我的问题的地方:

mvnw clean
mvnw compile

对于Gradle:

gradlew clean
gradlew compileJava

然后在IDE中刷新项目并运行它。

答案 3 :(得分:1)

我遇到了这个问题,这只是我pom.xml的一个问题。我需要将mapstruct添加到maven编译器插件中,如下所示:

...

<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>

答案 4 :(得分:0)

下次,请添加用于构建/启动应用程序的命令行并使用代码格式,以便为您的问题提供良好的格式。 ; o)

所以,根据这个日志,我建议你使用IDE和dev maven profil。 我很确定你不使用它,所以mapstruct有bean的接口但没有生成实现类。

相关问题