Comments (8)
明白了,懂了,多谢解惑哈
from pojo2json.
是支持扫描父类的,你可以自己写个继承关系试试。
之所以扫描不到jar中的父类是因为你的jar包没有关联源码导致的,IDEA会给有源码的依赖创建index,这样你才能点过去,而这个插件就是靠这个索引扫描的,你需要首先确认一下IDEA是否能正确识别这个jar。并且按住ctrl键可以进入到jar中的源码文件 (*.java)
from pojo2json.
就是说必须要是关联了源码的才可以是吧,点过去是java文件的那种才能行是吧。
但是我这个这个直接就是class文件也是可以支持的吧,拿到当前上下文的class,然后再去获取父类,这种不可以吗,是被idea屏蔽了吗
from pojo2json.
也不是被IDEA屏蔽了,就是你在IDEA看到的class文件是IDEA帮你反编译过的,实际上字节码不是人可读的。
但IDEA也仅仅是反编译字节码,不会对字节码本身建立抽象语法树。而抽象语法树是IDEA对各种语言解析的基础,这个插件其实是调用IDEA提供的抽象语法树进行java语法解析的。
当然IDEA可能也提供了解析字节码并还原成抽象语法树的方法,也可能没有,但无论怎样至少IDEA的文档中没有提供相关信息。
https://www.jetbrains.com/help/idea/getting-started.html
from pojo2json.
好的,那可以通过反射的方式实现吗,而不是通过idea提供的api,拿到这个class,然后去遍历所有field
from pojo2json.
一般反射是在一个jvm实例下进行的,IDEA是反射不了你的项目的任何class文件的,IDEA和你的项目是不同的进程。IDEA 解析项目是通过它自己的语法树引擎实现的。你不能把IDEA看作是你项目的一部分吧
from pojo2json.
可以这样实现吗,重写一个classLoader,从磁盘上面加载文件,就可以实现在idea项目中加载我的项目class了,然后就可以获取到class对象
from pojo2json.
我觉得正确的做法是说服你的上游使用这个插件。
<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)
- Support for member class HOT 4
- 功能请求:模拟实际使用的随机值 HOT 6
- 可否不直接进入某个类文件,用于支持泛型 HOT 1
- RFC: I want this plugin to integrate with HTTP Client plugin. HOT 3
- Consider adding the possibility of setting max string size for random values HOT 5
- StackOverflow on Idea 2022.2 HOT 4
- Unable to handle JsonNode HOT 4
- 快捷使用建议: 上调复制JSON的层级以及增加新的快捷栏目. HOT 1
- 一个java bean里没有`key`字段,但有`getKey`方法,支持copyToJson吗? HOT 2
- 大佬请教下,依赖包里的类无法转换么? HOT 2
- 1.2.6版本 copy json and random values 时报了NPE HOT 5
- 是否考虑添加带注释的转换选项? HOT 2
- RFC: Support snake_case in the Json keys HOT 1
- 是否考虑加一个选项,在最外面包一层 code data message 这种的 HOT 3
- Map, MultiValuedMap converts to empty section HOT 1
- List<HashMap<String,String>>会提示This class reference level exceeds maximum limit or has nested references! HOT 1
- 先前版本支持copy不生成随机值,现版本不支持?或在哪里设置。文档未说明 HOT 6
- 目前不支持scala的case class,是否考虑适配一下scala的case class HOT 1
- Incompatible with Idea 2024.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pojo2json.