IntelliJ IDEA:如何使依赖库的源在编译的类路径中可用?

编程入门 行业动态 更新时间:2024-10-26 09:27:24
本文介绍了IntelliJ IDEA:如何使依赖库的源在编译的类路径中可用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在使用IntelliJ IDEA 11。

当我将Global Library添加到模块并且工件IDE从不复制源和javadoc时。这是有道理的,因为它们在运行时不需要。但我在编译时需要它们。

有趣的是,如果我将依赖项作为文件夹添加,IDEA 使得源可用。我猜在这种情况下,它不会区分该文件夹中的内容。奇怪。

想法?

解决方案

具有我定义的源的那个:

分类:源 范围:提供 $ b

EX:

< dependency> < groupId> org.hibernate< / groupId> < artifactId> hibernate-validator< / artifactId> < version> 4.1.0.Final< / version> <排除项> <排除> < groupId> javax.xml.bind< / groupId> < artifactId> jaxb-api< / artifactId> < /排除> <排除> < groupId> com.sun.xml.bind< / groupId> < artifactId> jaxb-impl< / artifactId> < /排除> < /排除> < /依赖关系> < dependency> < groupId> org.hibernate< / groupId> < artifactId> hibernate-validator< / artifactId> < version> 4.1.0.Final< / version> < classifier> sources< / classifier> < scope>提供< / scope> < /依赖关系>

How can I make sources of dependent libraries to be available in classpath on compilation ?

I'm using IntelliJ IDEA 11.

When I add Global Library to module and artifact IDE never copies sources and javadocs. That makes sense because they are not needed in runtime. But I need them in compile time.

Interestingly though IDEA makes sources available if I add dependency as folder. I guess in this case it doesn't differentiate what sits in that folder. Odd.

Thoughts ?

解决方案

i solved this issue in maven config by specifying another dependency to hibernate-validator one with sources and one without.

the one with sources i defined:

classifier: sources scope: provided

EX:

<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.1.0.Final</version> <exclusions> <exclusion> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> </exclusion> <exclusion> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.1.0.Final</version> <classifier>sources</classifier> <scope>provided</scope> </dependency>

更多推荐

IntelliJ IDEA:如何使依赖库的源在编译的类路径中可用?

本文发布于:2023-11-13 12:01:05,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   IntelliJ   IDEA

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!