Giter VIP home page Giter VIP logo

Comments (8)

yangfeng20 avatar yangfeng20 commented on May 28, 2024 1

明白了,懂了,多谢解惑哈

from pojo2json.

organics2016 avatar organics2016 commented on May 28, 2024

是支持扫描父类的,你可以自己写个继承关系试试。
之所以扫描不到jar中的父类是因为你的jar包没有关联源码导致的,IDEA会给有源码的依赖创建index,这样你才能点过去,而这个插件就是靠这个索引扫描的,你需要首先确认一下IDEA是否能正确识别这个jar。并且按住ctrl键可以进入到jar中的源码文件 (*.java)

from pojo2json.

yangfeng20 avatar yangfeng20 commented on May 28, 2024

就是说必须要是关联了源码的才可以是吧,点过去是java文件的那种才能行是吧。
但是我这个这个直接就是class文件也是可以支持的吧,拿到当前上下文的class,然后再去获取父类,这种不可以吗,是被idea屏蔽了吗

from pojo2json.

organics2016 avatar organics2016 commented on May 28, 2024

也不是被IDEA屏蔽了,就是你在IDEA看到的class文件是IDEA帮你反编译过的,实际上字节码不是人可读的。
但IDEA也仅仅是反编译字节码,不会对字节码本身建立抽象语法树。而抽象语法树是IDEA对各种语言解析的基础,这个插件其实是调用IDEA提供的抽象语法树进行java语法解析的。
当然IDEA可能也提供了解析字节码并还原成抽象语法树的方法,也可能没有,但无论怎样至少IDEA的文档中没有提供相关信息。
https://www.jetbrains.com/help/idea/getting-started.html

from pojo2json.

yangfeng20 avatar yangfeng20 commented on May 28, 2024

好的,那可以通过反射的方式实现吗,而不是通过idea提供的api,拿到这个class,然后去遍历所有field

from pojo2json.

organics2016 avatar organics2016 commented on May 28, 2024

一般反射是在一个jvm实例下进行的,IDEA是反射不了你的项目的任何class文件的,IDEA和你的项目是不同的进程。IDEA 解析项目是通过它自己的语法树引擎实现的。你不能把IDEA看作是你项目的一部分吧

from pojo2json.

yangfeng20 avatar yangfeng20 commented on May 28, 2024

可以这样实现吗,重写一个classLoader,从磁盘上面加载文件,就可以实现在idea项目中加载我的项目class了,然后就可以获取到class对象

from pojo2json.

organics2016 avatar organics2016 commented on May 28, 2024

我觉得正确的做法是说服你的上游使用这个插件。

        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.2.1</version>

包含源码不意味着开源或不安全,在私有repo中能得到更好的可维护性。在maven**repo中包含src是必要条件。你应该检查你的jar是否合规,而不是把这看作一个工程问题。
https://central.sonatype.org/publish/publish-maven/#javadoc-and-sources-attachments
当然POJO to JSON是遵循MIT开源的,你可以实现你的任何想法。这里我们欢迎每个人的PR

from pojo2json.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.