IntelliJ IDEA:如何使依赖库的源在编译的类路径中可用? [英] IntelliJ IDEA: How can I make sources of dependent libraries to be available in classpath on compilation?

查看:703
本文介绍了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:如何使依赖库的源在编译的类路径中可用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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