为什么我的Java项目仍然可以工作,即使缺少了一些包?

huangapple go评论83阅读模式
英文:

Why does my java project still work even though its missing some packages?

问题

我正在处理一个 Dubbo 项目,当我深入研究它的源代码时,我在 Dubbo 的源代码中找到了以下代码:

为什么我的Java项目仍然可以工作,即使缺少了一些包?

我认为这显示了我的项目缺少 org.jboss.*
IDEA 已经将这些包标记为红色

但不知何故,这个项目仍然在工作,难道它不应该因为缺少一些包而无法工作吗?

顺便说一下,我的项目是由 gradle 组织的,build.gradle 如下:

dependencies 
{
        implementation 'org.springframework.boot:spring-boot-starter'
    	testImplementation('org.springframework.boot:spring-boot-starter-test') {
    		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    	}
    	compile group: 'org.apache.dubbo', name: 'dubbo-spring-boot-starter', version: '2.7.8'
    	compile group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.6.2'
    	compile group: 'org.apache.curator', name: 'curator-framework', version: '5.1.0'
}
英文:

I am working on a Dubbo project and when I digging a little deep into its source code. I found these code in Dubbo's source code:

为什么我的Java项目仍然可以工作,即使缺少了一些包?

I think this shows that my project missing the org.jboss.*package
(IDEA has mark these packages in red)

But somehow this project still working, doesn't it supposed to not working due to it has some package missing?

By the way my project is organized by gradle and the build.gradle is like this:

dependencies 
{
        implementation 'org.springframework.boot:spring-boot-starter'
    	testImplementation('org.springframework.boot:spring-boot-starter-test') {
    		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    	}
    	compile group: 'org.apache.dubbo', name: 'dubbo-spring-boot-starter', version: '2.7.8'
    	compile group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.6.2'
    	compile group: 'org.apache.curator', name: 'curator-framework', version: '5.1.0'
}



</details>


# 答案1
**得分**: 1

如果这不是某个库的反编译字节码,而是你的应用程序源代码,那么这可能是个问题。而且并没有遗漏任何东西,但是 Gradle 会根据需要引入 [`org.jboss.netty`](https://mvnrepository.com/artifact/io.netty/netty),然后会引入另外8个库,甚至可能会进一步引入其他库。

<details>
<summary>英文:</summary>

If this wouldn&#39;t be some library&#39;s de-compiled byte-code but your application&#39;s source code, this would rather be an issue. And it&#39;s not missing anything, but Gradle will pull in [`org.jboss.netty`](https://mvnrepository.com/artifact/io.netty/netty) on demand, which will then pull in another 8 libraries, which may evetually even pull in further libraries.

</details>



huangapple
  • 本文由 发表于 2020年10月7日 10:02:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/64236175.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定