Annotations vs XML, advantages and disadvantages(注释 vs XML,优点和缺点)
问题描述
我是这里的java新手,我正在阅读注释和xml,我个人发现xml有很多优点,比如它可以放在应用程序之外,可以在不重新编译类文件的情况下进行更改.如果我使用注释,如果我需要进行更改,则需要转到源代码并重新编译.如果是这种情况,我们为什么要使用注释
i am new to java here, I was reading about annotations and xml, personally I find out xml has lot of advantages like it can be put outside application, changes can be made without recompiling class files. If i use annotations if I need to make changes need to go to source code and recompiling should be done. If this is the case why should we use annotations
推荐答案
注解的优点:
1) 所有信息都在一个文件中(无需打开两个文件来配置给定的行为)
2)类发生变化时,无需修改xml文件
1) All the information is in a single file (no need to open two files to configure a given behavior)
2) When the class changes, no need to modify the xml file
xml文件的优点:
1) POJO 与其行为之间的明确分离
2)当你不知道哪个POJO对行为负责时,更容易找到那个POJO(在文件子集而不是所有源代码中搜索)
1) Clear separation between the POJO and its behavior
2) When you do not know which POJO is responsible for the behavior, it is easier to find that POJO (searching in a subset of files rather than all the source code)
这篇关于注释 vs XML,优点和缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:注释 vs XML,优点和缺点


- C++ 和 Java 进程之间的共享内存 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01