简体   繁体   English

Java:找出缺少符号的原始包

[英]java: figuring out origin package of missing symbol

I'm noticing that most Java web dev tutorials I come by are designed for people using an IDE and/or Maven instead of the Ant/text-editor combo that I use. 我注意到,我所获得的大多数Java Web开发教程都是为使用IDE和/或Maven而不是我使用的Ant /文本编辑器组合的人们设计的。

I've learned to determine where the POM.xml excerpts download the deps by using http://mvnrepository.com/ , but I'm still having a hard time determining the proper import statements when the tutorial omits them. 我已经学会了使用http://mvnrepository.com/来确定POM.xml摘录的下载位置,但是当本教程忽略它们时,我仍然很难确定正确的导入语句。

Sometimes, I've found that even if I find the docs, I may find that there's no obvious way to determine a symbol's package of origin . 有时,我发现即使找到文档,也可能发现没有明显的方法来确定符号的来源包 (try to find out which package @Produces belongs to) . (尝试找出@Produces属于哪个包)

So, here's the scenario: you try to compile and you find out there's a missing symbol and you have no idea where that symbol is supposed to come from. 因此,这是一种情况:您尝试进行编译,发现其中缺少一个符号,并且您不知道该符号应该来自何处。 What do you do? 你是做什么? Other than chasing geese on Google all day, how do I determine the import statement when it's missing from the tutorial? 除了整日在Google上追逐鹅,当教程中缺少导入语句时,如何确定导入语句?

Thanks in advance. 提前致谢。

EDIT: 编辑:

I've figured out that I can construct an import statement by using the file hierarchy in the unzipped jar file ( for instance, jersey-multipart-1.19/com/sun/jersey/multipart becomes import com.sun.jersey.multipart.* ). 我发现可以使用解压缩的jar文件中的文件层次结构来构造导入语句(例如, jersey-multipart-1.19/com/sun/jersey/multipart变为import com.sun.jersey.multipart.* )。 But that still doesn't necessarily tell me how to go the other direction, eg to find out where @Produces is defined. 但这并不一定告诉我如何去做另一个方向,例如找出@Produces的定义位置。

During development one can use the search index that comes with Maven Central to find the modules containing missing classes: 在开发过程中,可以使用Maven Central随附的搜索索引来查找包含缺少类的模块:

http://search.maven.org/ http://search.maven.org/

Better yet, deploy a local Maven repository manager like Nexus , Artifactory or Archiva . 更好的是,部署本地的Maven存储库管理器,例如NexusArtifactoryArchiva These would mirror Maven central's index and also index any local jars you might publish. 这些将反映Maven Central的索引,并索引您可能发布的任何本地jar。

Finally I highly recommend integrating one of the dependency management plugins for ANT. 最后,我强烈建议为ANT集成依赖管理插件之一。 Life is too short to be manually resolving nested java dependencies :-) 生命太短,无法手动解决嵌套的Java依赖项:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM