Rol*_* W. 13 java intellij-idea maven autofactory
我正在使用谷歌AutoFactory的注释处理器.我注释SomeClass与@AutoFactory和引用的new SomeClassFactory().create()是同一个模块在其他地方.
我在Maven中添加了必要的依赖:
<dependency>
<groupId>com.google.auto.factory</groupId>
<artifactId>auto-factory</artifactId>
<version>1.0-beta2</version>
<optional>true</optional>
</dependency>
Run Code Online (Sandbox Code Playgroud)
运行时,$ mvn clean compile我看到它target/generated-sources/annotions/somepackage/SomeClassFactory已创建,模块编译没有错误.
Reimport all maven modulesPreferences- > Annotation Processors- >Enable annotation processingRebuild Projectv14.1.4如果我的理解是正确的,那么在我的IDEA()版本中这应该足够了.
我还执行了以下步骤:
generated-sources文件夹已添加为源Project StructureGenerated sources folders已设置为Detect automaticallytarget首先删除文件夹以确保它是由IntelliJ生成的)Exclude output paths按照@tilpner的建议在项目结构中禁用.idea文件夹和.iml文件Phase to be used for folders updatein Preferences- > Maven- >的不同设置Importing执行所有这些步骤后,生成的类不会显示在项目资源管理器中.实际上,整个target目录都无处可见.编译失败,cannot find symbol: SomeClassFactory
并new SomeClassFactory().create()在编辑器中以红色标记,而Maven生成并编译没有任何问题.
我自己没有选择,非常欢迎任何帮助或建议!
更新:当我评论导致编译错误的代码时,IntelliJ在编译消息中打印此警告:Warning:Output path /Users/.../target/generated-sources/annotations intersects with a source root. Only files that were created by build will be cleaned.
Rol*_* W. 15
我得到了Jetbrains支持的帮助,结果问题是对排除文件的偏好.这些配置有两个地方:
请检查文件夹/文件是否未排除,
Preferences > Build, Execution, Deployment > Compiler > Excludes文件/文件夹模式未列在Preferences > Editor > File Types -> Ignored files and folders
在我的情况下target,包含在Editor> 中被忽略的文件和文件夹列表中File Types.
然后还有一个编译问题,我通过丢弃IDEA项目文件并再次创建项目来解决.
| 归档时间: |
|
| 查看次数: |
10838 次 |
| 最近记录: |