JAXB异常: Error parsing XML file at xxx Caused by 类的两个属性具有相同名称

OpenFoam实用技巧——starccm网格高效转换openfoam格式全解析 本文详细解析了如何利用OpenFOAM官方工具`ccm26toFoam`,将STAR-CCM+生成的高质量网格高效、稳定地转换为OpenFOAM格式。内容涵盖从STAR-CCM+正确导出网格、执行转换命令、解读转换日志,到转换后关键的边界条件修复与网格质量检查等全流程,旨在帮助用户规避常见错误,实现无缝工作流衔接。 阅读详情

异常信息

Exception in thread “main” java.lang.RuntimeException: Error parsing XML file at com.nn.dataprocess.utils.XmlParserUtil.parseXmlFile(XmlParserUtil.java:29) at com.nn.dataprocess.sevice.impl.XmlConfigReaderImpl.loadConfiguration(XmlConfigReaderImpl.java:32) at com.nn.dataprocess.sevice.DataProcessor.processData(DataProcessor.java:33) at com.nn.dataprocess.AppStarter.main(AppStarter.java:41) Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions 类的两个属性具有相同名称 “id”

异常出现的场景:

使用JAXB,读取配置文件,转换成实体类后(正常),主方法使用了该类的toString()方法。

异常代码块:

@Data
@XmlRootElement(name = "dataprocess")
public class DataTransformationSettingsDTO implements PropertyAccessor {

    @XmlAttribute(name = "id")
    private String id;  //数据加工程序编码 一般是数字;

    @XmlAttribute(name = "type")
    private String type;    // 一般指数据加工的类型,全量/增量; 日/月接口; 增量-P 全量-F

    @XmlAttribute(name = "isProvince")
    private boolean eProvince;  // 是否是省份 非必需
	
	// 省略其他属性
}

异常原因分析和解决:

在使用 JAXB 进行 XML 到 Java 对象的映射时,@Data 注解可能会导致问题,因为它会生成 toString 方法,而 toString 方法可能包含属性的名称,这可能会与 XML 中的属性名冲突。

也就是说 @Data (Lombok的注解) 的影响,可以尝试使用 @XmlAccessorType(XmlAccessType.FIELD) 注解在类级别,以告知 JAXB 在映射时只考虑类的字段,而忽略 toString 等方法。

解决后的代码

@Data
@XmlRootElement(name = "dataprocess")
@XmlAccessorType(XmlAccessType.FIELD)
public class DataTransformationSettingsDTO implements PropertyAccessor {

    @XmlAttribute(name = "id")
    private String id;  //数据加工程序编码 一般是数字;

    @XmlAttribute(name = "type")
    private String type;    // 一般指数据加工的类型,全量/增量; 日/月接口; 增量-P 全量-F

    @XmlAttribute(name = "isProvince")
    private boolean eProvince;  // 是否是省份 非必需
	
	// 省略其他属性
}

得到的经验:
就是 Lombok 虽然用的很多,但是还是有很多的坑需要注意。

11-16 Fluent结果查看及后处理功能(做动画、监控点) 监控点、面及动画操作 阅读详情

相关推荐

告别繁琐同步:Zotero与Obsidian双向联动新方案(基于Better BibTeX与MarkDBConnect)

本文详细介绍了一套基于Better BibTeX、Bibnotes Formatter和MarkDBConnect插件的Zotero与Obsidian双向联动方案。该方案通过建立智能数据通道,实现文献信息的自动同步与笔记的增量更新,解决了手动同步的繁琐问题,并支持在两大工具间无缝跳转,极大提升了科研和知识管理的工作效率。

weixin_29213827的博客 646

xml 转对象报错:类的两个属性具有相同名称

今天在用 jaxb 做 xml 转对象时,遇到俩问题。先记录一下: ① 意外的元素(uri:"",local:"root")。所需元素为(none) ② jaxb对象转xml报错:类的两个属性具有相同名称lombok(@Data)

qianqian的博客 5434

OpenWRT软件源更换保姆级教程:从国内镜像到官方源一键切换(含常见报错解决)

本文提供OpenWRT软件源更换的详细教程,涵盖从国内镜像源到官方源的切换方法,并深度解析常见报错解决方案。针对国内网络环境,指导用户如何精准定位系统信息、备份配置、选择并配置清华等国内镜像源,以及处理签名验证失败、依赖缺失、404错误等典型问题,旨在提升软件包管理效率与稳定性。

weixin_29229261的博客 1949

jaxb 对象转xml 报错:类的两个属性具有相同名称 lombok(@Data)

此问题在工作当中遇到过三次了,每次对象嵌套转xml就遇到此问题,这次记录下,以便下次遇到,能百度到自己的记录来解决!!!!! 异常: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 类的两个属性具有相同名称 "examinationItemDetails" 按照我当前类的写法 得需要从get方法上加@XmlTransient来避免此错误,因为想用lombok.

yzshen123456的博客 4223

从零复刻平衡小车(基于STM32F1)

平衡小车(基于STM32F1)

Legendyyy的博客 5046

海康视觉平台VisionMaster实战入门:从通讯配置到工具应用

本文为海康VisionMaster视觉平台实战入门指南,详细介绍了从软件安装准备、与PLC等外部设备的通讯配置,到匹配定位、测量、畸变矫正等核心工具的应用方法。通过实战案例拆解,帮助工程师快速掌握如何搭建完整的机器视觉检测与引导定位系统,实现工业自动化项目落地。

weixin_29224309的博客 1026

错误com.sun.xml.internal.bind.v2.runtime.IllegalAnno

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33753845的博客 1877

开关电源EMC整改案例-辐射骚扰

2.4.1 获得原始数据。同样的分析可以应用在差模电流的情况, 唯一不同的是, 两根导线的磁场分布是相反的, 磁 场互相抵消, 由于导线中的电流大小相等, 产生的磁场 H 大小相同, 在互相靠近的情况下, 在磁 环内的两个感应磁场大小相同、方向相反, 因此合成之后的感应磁场 B 几乎为 0,对任意一根导 线而言,相当于是一段“无感导线”,对差模电流不会产生任何抑制作用。众所周知, 共模电感的匝数越多, 感量越大, 按道 理来说对共模干扰电流的抑制也会越强烈,对抗辐射 也越有利,然而事实真的如此吗?

经营范围: CTA、SRRC、CCC、移动、电信、联通入库 3507

类的两个属性具有相同名称 报错解决

今天在将xml报文转换为model时遇到报错时遇到一个报错,如下: 类的两个属性具有相同名称 "iDistrictCode" this problem is related to the following location: at public java.lang.String com.baobao.InsuranceApi.model.EInvoiceApplyReq.getiDistr...

Be Like 9506

第1集:认识 Claude Code —— AI 编程新纪元

1. 定义 Claude Code:终端中的 AI 编程代理Claude Code 是 Anthropic 公司于 2025 年 5 月正式推出的命令行 AI 编程工具,它不只是一个代码补全工具,而是一个能够理解项目、自主执行任务的**终端 AI 代理(Agent)。它的核心理念是 **"生于终端,活于终端"** (lives in your terminal)。与深度嵌入图形界面(GUI)的工具不同,Claude Code 选择直接融入开发者最原始、最核心的工作环境——命令行。

dianziyao_的博客 868

【腾讯小龙虾 WorkBuddy 专栏 03】技能(Skills)制作全教程!自定义技能编写、导出分享、导入使用一步到位

🔥腾讯AI智能体WorkBuddy自定义技能全攻略 本文为零基础用户提供WorkBuddy自定义技能的完整教程,涵盖技能概念、编写规范到实操全流程。核心内容包括: 技能本质:标准化任务指令模板,可固化重复操作流程 三大价值:一键执行重复任务/跨设备共享/降低使用门槛 实操演示:以"桌面文档自动分类"为例,分步讲解编写、测试、导出 共享方案:支持单技能/批量导出,通过任意渠道传输分享 导入指南:3秒完成他人技能加载,并提供常见问题解决方案 高阶优化:增加异常处理、版本管理等提升技能普适性

AI人人懂 2993

JAXB “有两个名为 “**“ 的属性,类的两个属性具有相同名称 “**““解决方案

JAXB "有两个名为 "**" 的属性,类的两个属性具有相同名称 "**""解决方案

w36680130的博客 328

ABAP 平台 SOAUTH2_CLIENT 全面实战:用一套配置,打通 OAuth 2.0 客户端的创建、联调与运维

本文是一份ABAP平台上配置OAuth 2.0客户端的全流程指南,重点介绍新界面SOAUTH2_CLIENT的使用方法。内容涵盖从概念解析到实操步骤,包括四种常见授权方式的选择、证书信任管理、Scope配置以及联调技巧。指南通过两个企业级案例(对接SAP BTP Cloud Integration和SAML 2.0身份联合)展示实际应用场景,并提供了配置清单和伪代码示例。特别强调新界面将客户端配置、令牌测试和校验功能整合的工程化优势,以及与旧事务码OA2C_CONFIG的主要差异。文中多处引用SAP官方文档

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 319

学习webservice之cxf(5):cxf处理map等复杂类型

Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions java.util.List是接口, 而 JAXB 无法处理接口。 this problem is related to the following ...

weixin_30314631的博客 326

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

JAXB "有两个名为 "**" 的属性,类的两个属性具有相同名称 "**""解决方案

用eclipse写JAXB时,发现总是报这样的错。     这是为什么呢? 在网上搜索到的jaxb2的中文教程很少,而且内容太过简单,查阅了一些英文的资料,发现问题是“名称的冲突”。 这里说的名称冲突指的是: JavaBean 属性名称与字段名称之间的名称冲突。 在pojo类中的setter和getter方法会导致运行报错: Exception in thread "mai

淡然坊 1万+

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

JAXB,Model生成XML错误!类的两个属性具有相同名称,报错

如果每个都报错了,可能是成员变量或者get/set方法问题,model转xml的model类为public,成员变量为私有,get/set方法为公有。检查一遍成员变量是否为私有。 如果只报错一两个属性,则可在get方法上加@XmlTransient注解忽略(如果该属性不重要的话) 或者 ...

一个Ass很大的monkey的博客 1136

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Exception:两个类具有相同的 XML 类型名称,请使用 @XmlType.name 和 @XmlType.namespace 为类分配不同的名称

解决办法: 改动 @XmlType中的name,让name与下方类名不同,不区分大小写,所有必须输入不一样的字符窜 Exception in thread “main” com.sun.xml.internal.ws.spi.db.DatabindingException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsExcept...

weixin_43934363的博客 3028

CXF 发布WS 1 counts of IllegalAnnotationExceptions 问题

今天第一次用CXF开发WebService ,在开发的过程中遇到一个问题错误如下: Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name

liutieniu87的专栏 5958

类中两个属性具有相同名称bug

类中两个属性具有相同名称bug, 类中成员变量作用域应该为private。 com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions 类的两个属性具有相同名称 "name" this problem is related to the following location: at public java.util.List cn.excerci

我的博客 2138

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions

springboot + webservice 项目启动失败,报com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions错误。因为@WebService注解的类中有两个public方法,把public方法改成private问题解决,重新启动项目,启动成功。

rucheng1的博客 1621

Error parsing XML: XML declaration not well-formed

这个错误翻译过来是——解析XML时出错:XML声明格式不正确。报错的xml语言如下所示,将<?xml version="1.0"encoding="utf-8"?>改成<?xml version="1.0" encoding="utf-8"?>即可,就是在veision和encoding之间加一个空格 ...

weixin_37119423的博客 2470

om.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions

om.sun.xml.bind.v2.runtime.IllegalAnnotationsException:1 counts of IllegalAnnotationExceptions

rendeyishi的专栏 2万+

报错error:Error parsing XML:unbound prefix的解决办法

报error:Error parsing XML:unbound prefix这个错误通常是在xml布局文件中,大多数原因都是因为缺少命名空间或者使用了自定义控件。所以需要检查一下是否使用了其他的标签。 下面是我遇到这个错误的两个例子:第一个是使用了PreferenceScreen属性,只在标签中添加了 xmlns:android=”http://schemas.android.com/apk/

哆啦U梦的博客 9450

JAVA: 使用JAXB报类的两个属性具有相同名称“

将@XmlElement注解放在getter上,而不是属性上

amadeus_liu2的博客 1197

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions

通过JABX技术,把xml转换为实体类时候发生IllegalAnnotationExceptions 错误,是由于属性中一个参数设置为private 更改为public 后问题解决

weixin_41024965的博客 4373

webservice发布小问题

Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions java.util.List is an interface, and JAXB c

baby舞 2564
上一篇: Maven打包缺少system依赖,临时救急的方法 简单而有效
下一篇: IDEA 内置数据库操作工具 告别窗口切换 降本增效
知楠行易
博客等级 码龄9年 320粉丝 56原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值