我如何配置IntelliJ / gradle使用匕首2.0 [英] How do I configure IntelliJ/gradle to use dagger 2.0

查看:206
本文介绍了我如何配置IntelliJ / gradle使用匕首2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gradle项目,我想在其中使用匕首2.0。我不知道如何配置IntelliJ和gradle来生成文件,并让IntelliJ找到它们?

I have a gradle project and I want to use dagger 2.0 in it. I don't know how to configure IntelliJ and gradle to generate files and let IntelliJ find them?

我的build.gradle文件如下所示:

My build.gradle file looks like:

apply plugin: 'java'
apply plugin: 'idea'

version = '1.0'

repositories {
    mavenCentral()
    maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.12'
    compile 'org.slf4j:slf4j-simple:1.7.12'
    compile 'commons-configuration:commons-configuration:1.10'
    compile 'commons-collections:commons-collections:3.2.1'
    compile 'com.google.dagger:dagger:2.0'
    compile 'com.google.dagger:dagger-compiler:2.0:jar-with-dependencies'
    compile 'com.pi4j:pi4j-distribution:1.1-SNAPSHOT'
}

在我的应用程序的构建目录中,文件 DaggerXmlConf igurationComponent 存在,这是Dagger创建的组件。但我无法在IntelliJ中使用它,因为它找不到该类。

In the build directory of my application the file DaggerXmlConfigurationComponent exists, which is a component Dagger creates. But I can't use it in IntelliJ because it can't find the class.

这不是Android应用程序,而是Raspberry Pi的应用程序。

This is not an Android application but an application for the Raspberry Pi.

推荐答案

您必须手动为IntelliJ启用注释处理:在设置...→构建,执行,部署→编译器→注释处理器,检查启用注释处理并从项目类路径获取处理器。

You'll have to manually enable annotation processing for IntelliJ: in Settings… → Build, Execution, Deployment → Compiler → Annotation Processors, check Enable annotation processing and Obtain processors from project classpath.

这篇关于我如何配置IntelliJ / gradle使用匕首2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆