我是第一次使用 JAXB,在理解它要我做什么时遇到了一些问题。
我已经设置了一个类,它将成为一个相当大的 XML 的一部分 - 这个类将代表 XML 文档的“标题”部分。
package com.somecompany.jscentral.xml.integrator.soc;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.somecompany.jscentral.xml.AbstractXML;
@XmlRootElement(name = "Header")
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(propOrder = {"OrderRoutine", "CreationDate", "CreationTime", "UserId", "CustomerNumber",
"OrderType", "Salesman", "Handler", "Warehouse", "PrimaryCurrency", "OrderNumber",
"Name", "OrderDate", "DeliveryAddressNumber", "ConfirmationAddressNumber", "FullName999",
"CompanyName999", "StreetAddress999Line1", "StreetAddress999Line2", "City999", "StateProvince999",
"PostCode999", "Country999", "Resale999", "InvoiceCustomerNumber", "CustomerReference",
"NumberOfInvoiceCopies", "Language", "VAT", "Backlog", "OrderDiscountPercent", "DiscountGroup",
"PriceCode", "StandardTextNumber", "HoldOrder", "TermsOfPayment", "CreditDays", "TermsOfDelivery",
"MannerOfTransport", "FreightFee", "PostageFee", "InsuranceFee", "AdministrationFee", "InvoiceFee",
"CustomersOrderNumberReference", "GoodsMarking", "HoldInvoice", "DeliveryAddressEngineer",
"DeliveryAddressLocation", "CountryDispatchedToArrivedFrom", "VATRegNumberOfDebtorAddr",
"NatureOfTransaction", "VATHandlingCode", "PortOfArrivalDispatch", "CountryOfTrader", "InternalOrder",
"ToWarehouse", "RouteId", "DepartureId", "DestinationId", "ShippingAgent", "ContactListCode",
"Salesman2", "CreationDate2", "Sequence", "DebtorNumber", "DebtorAddressNumber", "InvoiceAddressNumber",
"WebOrder", "Confirmed", "ClientIdentity"})
public class Header extends AbstractXML {
public Header() throws JAXBException {
super();
}
@XmlElement(name = "OrderRoutine", required = true)
private String orderRoutine;
public void setOrderRoutine(String orderRoutine) {
this.orderRoutine = orderRoutine;
}
public String getOrderRoutine() {
return this.orderRoutine;
}
@XmlElement(name = "CreationDate", required = false)
private String creationDate;
public void setCreationDate(String creationDate) {
this.creationDate = creationDate;
}
public String getCreationDate() {
return this.creationDate;
}
@XmlElement(name = "CreationTime", required = false)
private String creationTime;
public void setCreationTime(String creationTime) {
this.creationTime = creationTime;
}
public String getCreationTime() {
return this.creationTime;
}
@XmlElement(name = "UserId", required = false)
private String userId;
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserId() {
return this.userId;
}
@XmlElement(name = "CustomerNumber", required = true)
private String customerNumber;
public void setCustomerNumber(String customerNumber) {
this.customerNumber = customerNumber;
}
public String getCustomerNumber() {
return this.customerNumber;
}
@XmlElement(name = "OrderType", required = true)
private String orderType;
public void setOrderType(String orderType) {
this.orderType = orderType;
}
public String getOrderType() {
return this.orderType;
}
@XmlElement(name = "Salesman", required = true)
private String salesman;
public void setSalesman(String salesman) {
this.salesman = salesman;
}
public String getSalesman() {
return this.salesman;
}
@XmlElement(name = "Handler", required = true)
private String handler;
public void setHandler(String handler) {
this.handler = handler;
}
public String getHandler() {
return this.handler;
}
@XmlElement(name = "Warehouse", required = true)
private String warehouse;
public void setWarehouse(String warehouse) {
this.warehouse = warehouse;
}
public String getWarehouse() {
return this.warehouse;
}
@XmlElement(name = "PrimaryCurrency", required = true)
private String primaryCurrency;
public void setPrimaryCurrency(String primaryCurrency) {
this.primaryCurrency = primaryCurrency;
}
public String getPrimaryCurrency() {
return this.primaryCurrency;
}
@XmlElement(name = "OrderNumber", required = false)
private String orderNumber;
public void setOrderNumber(String orderNumber) {
this.orderNumber = orderNumber;
}
public String getOrderNumber() {
return this.orderNumber;
}
@XmlElement(name = "Name", required = false)
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
@XmlElement(name = "OrderDate", required = false)
private String orderDate;
public void setOrderDate(String orderDate) {
this.orderDate = orderDate;
}
public String getOrderDate() {
return this.orderDate;
}
@XmlElement(name = "DeliveryAddressNumber", required = false)
private String deliveryAddressNumber;
public void setDeliveryAddressNumber(String deliveryAddressNumber) {
this.deliveryAddressNumber = deliveryAddressNumber;
}
public String getDeliveryAddressNumber() {
return this.deliveryAddressNumber;
}
@XmlElement(name = "ConfirmationAddressNumber", required = false)
private String confirmationAddressNumber;
public void setConfirmationAddressNumber(String confirmationAddressNumber) {
this.confirmationAddressNumber = confirmationAddressNumber;
}
public String getConfirmationAddressNumber() {
return this.confirmationAddressNumber;
}
@XmlElement(name = "FullName999", required = true)
private String fullName999;
public void setFullName999(String fullName999) {
this.fullName999 = fullName999;
}
public String getFullName999() {
return this.fullName999;
}
@XmlElement(name = "CompanyName999", required = true)
private String companyName999;
public void setCompanyName999(String companyName999) {
this.companyName999 = companyName999;
}
public String getCompanyName999() {
return this.companyName999;
}
@XmlElement(name = "StreetAddress999Line1", required = true)
private String streetAddress999Line1;
public void setStreetAddress999Line1(String streetAddress999Line1) {
this.streetAddress999Line1 = streetAddress999Line1;
}
public String getStreetAddress999Line1() {
return this.streetAddress999Line1;
}
@XmlElement(name = "StreetAddress999Line2", required = true)
private String streetAddress999Line2;
public void setStreetAddress999Line2(String streetAddress999Line2) {
this.streetAddress999Line2 = streetAddress999Line2;
}
public String getStreetAddress999Line2() {
return this.streetAddress999Line2;
}
@XmlElement(name = "City999", required = true)
private String city999;
public void setCity999(String city999) {
this.city999 = city999;
}
public String getCity999() {
return this.city999;
}
@XmlElement(name = "StateProvince999", required = true)
private String stateProvince999;
public void setStateProvince999(String stateProvince999) {
this.stateProvince999 = stateProvince999;
}
public String getStateProvince999() {
return this.stateProvince999;
}
@XmlElement(name = "PostCode999", required = true)
private String postCode999;
public void setPostCode999(String postCode999) {
this.postCode999 = postCode999;
}
public String getPostCode999() {
return this.postCode999;
}
@XmlElement(name = "Country999", required = true)
private String country999;
public void setCountry999(String country999) {
this.country999 = country999;
}
public String getCountry999() {
return this.country999;
}
@XmlElement(name = "Resale999", required = false)
private String resale999;
public void setResale999(String resale999) {
this.resale999 = resale999;
}
public String getResale999() {
return this.resale999;
}
@XmlElement(name = "InvoiceCustomerNumber", required = false)
private String invoiceCustomerNumber;
public void setInvoiceCustomerNumber(String invoiceCustomerNumber) {
this.invoiceCustomerNumber = invoiceCustomerNumber;
}
public String getInvoiceCustomerNumber() {
return this.invoiceCustomerNumber;
}
@XmlElement(name = "CustomerReference", required = false)
private String customerReference;
public void setCustomerReference(String customerReference) {
this.customerReference = customerReference;
}
public String getCustomerReference() {
return this.customerReference;
}
@XmlElement(name = "NumberOfInvoiceCopies", required = false)
private String numberOfInvoiceCopies;
public void setNumberOfInvoiceCopies(String numberOfInvoiceCopies) {
this.numberOfInvoiceCopies = numberOfInvoiceCopies;
}
public String getNumberOfInvoiceCopies() {
return this.numberOfInvoiceCopies;
}
@XmlElement(name = "Language", required = false)
private String language;
public void setLanguage(String language) {
this.language = language;
}
public String getLanguage() {
return this.language;
}
@XmlElement(name = "VAT", required = false)
private String vat;
public void setVAT(String vat) {
this.vat = vat;
}
public String getVAT() {
return this.vat;
}
@XmlElement(name = "Backlog", required = false)
private String backlog;
public void setBacklog(String backlog) {
this.backlog = backlog;
}
public String getBacklog() {
return this.backlog;
}
@XmlElement(name = "OrderDiscountPercent", required = false)
private String orderDiscountPercent;
public void setOrderDiscountPercent(String orderDiscountPercent) {
this.orderDiscountPercent = orderDiscountPercent;
}
public String getOrderDiscountPercent() {
return this.orderDiscountPercent;
}
@XmlElement(name = "DiscountGroup", required = false)
private String discountGroup;
public void setDiscountGroup(String discountGroup) {
this.discountGroup = discountGroup;
}
public String getDiscountGroup() {
return this.discountGroup;
}
@XmlElement(name = "PriceCode", required = false)
private String priceCode;
public void setPriceCode(String priceCode) {
this.priceCode = priceCode;
}
public String getPriceCode() {
return this.priceCode;
}
@XmlElement(name = "StandardTextNumber", required = false)
private String standardTextNumber;
public void setStandardTextNumber(String standardTextNumber) {
this.standardTextNumber = standardTextNumber;
}
public String getStandardTextNumber() {
return this.standardTextNumber;
}
@XmlElement(name = "HoldOrder", required = false)
private String holdOrder;
public void setHoldOrder(String holdOrder) {
this.holdOrder = holdOrder;
}
public String getHoldOrder() {
return this.holdOrder;
}
@XmlElement(name = "TermsOfPayment", required = true)
private String termsOfPayment;
public void setTermsOfPayment(String termsOfPayment) {
this.termsOfPayment = termsOfPayment;
}
public String getTermsOfPayment() {
return this.termsOfPayment;
}
@XmlElement(name = "CreditDays", required = false)
private String creditDays;
public void setCreditDays(String creditDays) {
this.creditDays = creditDays;
}
public String getCreditDays() {
return this.creditDays;
}
@XmlElement(name = "TermsOfDelivery", required = false)
private String termsOfDelivery;
public void setTermsOfDelivery(String termsOfDelivery) {
this.termsOfDelivery = termsOfDelivery;
}
public String getTermsOfDelivery() {
return this.termsOfDelivery;
}
@XmlElement(name = "MannerOfTransport", required = true)
private String mannerOfTransport;
public void setMannerOfTransport(String mannerOfTransport) {
this.mannerOfTransport = mannerOfTransport;
}
public String getMannerOfTransport() {
return this.mannerOfTransport;
}
@XmlElement(name = "FreightFee", required = true)
private String freightFee;
public void setFreightFee(String freightFee) {
this.freightFee = freightFee;
}
public String getFreightFee() {
return this.freightFee;
}
@XmlElement(name = "PostageFee", required = false)
private String postageFee;
public void setPostageFee(String postageFee) {
this.postageFee = postageFee;
}
public String getPostageFee() {
return this.postageFee;
}
@XmlElement(name = "InsuranceFee", required = false)
private String insuranceFee;
public void setInsuranceFee(String insuranceFee) {
this.insuranceFee = insuranceFee;
}
public String getInsuranceFee() {
return this.insuranceFee;
}
@XmlElement(name = "AdministrationFee", required = false)
private String administrationFee;
public void setAdministrationFee(String administrationFee) {
this.administrationFee = administrationFee;
}
public String getAdministrationFee() {
return this.administrationFee;
}
@XmlElement(name = "InvoiceFee", required = false)
private String invoiceFee;
public void setInvoiceFee(String invoiceFee) {
this.invoiceFee = invoiceFee;
}
public String getInvoiceFee() {
return this.invoiceFee;
}
@XmlElement(name = "CustomersOrderNumberReference", required = true)
private String customersOrderNumberReference;
public void setCustomersOrderNumberReference(String customersOrderNumberReference) {
this.customersOrderNumberReference = customersOrderNumberReference;
}
public String getCustomersOrderNumberReference() {
return this.customersOrderNumberReference;
}
@XmlElement(name = "GoodsMarking", required = true)
private String goodsMarking;
public void setGoodsMarking(String goodsMarking) {
this.goodsMarking = goodsMarking;
}
public String getGoodsMarking() {
return this.goodsMarking;
}
@XmlElement(name = "HoldInvoice", required = false)
private String holdInvoice;
public void setcustomersOrderNumberReference(String holdInvoice) {
this.holdInvoice = holdInvoice;
}
public String getcustomersOrderNumberReference() {
return this.holdInvoice;
}
@XmlElement(name = "DeliveryAddressEngineer", required = false)
private String deliveryAddressEngineer;
public void setDeliveryAddressEngineer(String deliveryAddressEngineer) {
this.deliveryAddressEngineer = deliveryAddressEngineer;
}
public String getDeliveryAddressEngineer() {
return this.deliveryAddressEngineer;
}
@XmlElement(name = "DeliveryAddressLocation", required = false)
private String deliveryAddressLocation;
public void setDeliveryAddressLocation(String deliveryAddressLocation) {
this.deliveryAddressLocation = deliveryAddressLocation;
}
public String getDeliveryAddressLocation() {
return this.deliveryAddressLocation;
}
@XmlElement(name = "CountryDispatchedToArrivedFrom", required = false)
private String countryDispatchedToArrivedFrom;
public void setCountryDispatchedToArrivedFrom(String countryDispatchedToArrivedFrom) {
this.countryDispatchedToArrivedFrom = countryDispatchedToArrivedFrom;
}
public String getCountryDispatchedToArrivedFrom() {
return this.countryDispatchedToArrivedFrom;
}
@XmlElement(name = "VATRegNumberOfDebtorAddr", required = false)
private String vatRegNumberOfDebtorAddr;
public void setVATRegNumberOfDebtorAddr(String vatRegNumberOfDebtorAddr) {
this.vatRegNumberOfDebtorAddr = vatRegNumberOfDebtorAddr;
}
public String getVATRegNumberOfDebtorAddr() {
return this.vatRegNumberOfDebtorAddr;
}
@XmlElement(name = "NatureOfTransaction", required = false)
private String natureOfTransaction;
public void setNatureOfTransaction(String natureOfTransaction) {
this.natureOfTransaction = natureOfTransaction;
}
public String getNatureOfTransaction() {
return this.natureOfTransaction;
}
@XmlElement(name = "VATHandlingCode", required = false)
private String vatHandlingCode;
public void setVATHandlingCode(String vatHandlingCode) {
this.vatHandlingCode = vatHandlingCode;
}
public String getVATHandlingCode() {
return this.vatHandlingCode;
}
@XmlElement(name = "PortOfArrivalDispatch", required = false)
private String portOfArrivalDispatch;
public void setPortOfArrivalDispatch(String portOfArrivalDispatch) {
this.portOfArrivalDispatch = portOfArrivalDispatch;
}
public String getPortOfArrivalDispatch() {
return this.portOfArrivalDispatch;
}
@XmlElement(name = "CountryOfTrader", required = false)
private String countryOfTrader;
public void setCountryOfTrader(String countryOfTrader) {
this.countryOfTrader = countryOfTrader;
}
public String getCountryOfTrader() {
return this.countryOfTrader;
}
// ETC...
}
这是堆栈跟踪:
Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 142 counts of IllegalAnnotationExceptions
Property orderRoutine is present but not specified in @XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.orderRoutine
at com.somecompany.jscentral.xml.integrator.soc.Header
Property creationDate is present but not specified in @XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.creationDate
at com.somecompany.jscentral.xml.integrator.soc.Header
Property creationTime is present but not specified in @XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.creationTime
at com.somecompany.jscentral.xml.integrator.soc.Header
Property userId is present but not specified in @XmlType.propOrder
this problem is related to the following location:
at private java.lang.String com.somecompany.jscentral.xml.integrator.soc.Header.userId
at com.somecompany.jscentral.xml.integrator.soc.Header
..等..
Property OrderRoutine appears in @XmlType.propOrder, but no such property exists. Maybe you meant orderRoutine?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property CreationDate appears in @XmlType.propOrder, but no such property exists. Maybe you meant creationDate?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property CreationTime appears in @XmlType.propOrder, but no such property exists. Maybe you meant creationTime?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
.. ETC ..
Property InvoiceAddressNumber appears in @XmlType.propOrder, but no such property exists. Maybe you meant invoiceAddressNumber?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property WebOrder appears in @XmlType.propOrder, but no such property exists. Maybe you meant webOrder?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property Confirmed appears in @XmlType.propOrder, but no such property exists. Maybe you meant confirmed?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
Property ClientIdentity appears in @XmlType.propOrder, but no such property exists. Maybe you meant clientIdentity?
this problem is related to the following location:
at com.somecompany.jscentral.xml.integrator.soc.Header
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
at javax.xml.bind.ContextFinder.find(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
at com.somecompany.jscentral.xml.AbstractXML.<init>(AbstractXML.java:21)
at com.somecompany.jscentral.xml.integrator.soc.Header.<init>(Header.java:33)
at com.somecompany.jscentral.xml.integrator.IntegratorSOCXML.main(IntegratorSOCXML.java:22)
我已经尝试了不同的@XmlAccessorType...但没有任何变化。我也尝试过用 @XmlTransient 注释这些方法,但没有区别。我究竟做错了什么?
最佳答案
propOrder 基于字段/属性名称而不是元素名称。如果您进行此更改,一切都会正常工作。
此外,如果您要注释字段,您应该在类中指定 @XmlAccessorType(XmlAccessType.FIELD)。
此外,由于我注意到您的模型中有继承,您不能在 propOrder 中包含继承的属性,除非您使用 @XmlTransient 标记零件类。
关于java - JAXB 非法注释异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18937472/
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我正在学习Rails,并阅读了关于乐观锁的内容。我已将类型为integer的lock_version列添加到我的articles表中。但现在每当我第一次尝试更新记录时,我都会收到StaleObjectError异常。这是我的迁移:classAddLockVersionToArticle当我尝试通过Rails控制台更新文章时:article=Article.first=>#我这样做:article.title="newtitle"article.save我明白了:(0.3ms)begintransaction(0.3ms)UPDATE"articles"SET"title"='dwdwd
在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee
我早就知道Ruby中的“常量”(即大写的变量名)不是真正常量。与其他编程语言一样,对对象的引用是唯一存储在变量/常量中的东西。(侧边栏:Ruby确实具有“卡住”引用对象不被修改的功能,据我所知,许多其他语言都没有提供这种功能。)所以这是我的问题:当您将一个值重新分配给常量时,您会收到如下警告:>>FOO='bar'=>"bar">>FOO='baz'(irb):2:warning:alreadyinitializedconstantFOO=>"baz"有没有办法强制Ruby抛出异常而不是打印警告?很难弄清楚为什么有时会发生重新分配。 最佳答案
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
这篇文章是继上一篇文章“Observability:从零开始创建Java微服务并监控它(一)”的续篇。在上一篇文章中,我们讲述了如何创建一个Javaweb应用,并使用Filebeat来收集应用所生成的日志。在今天的文章中,我来详述如何收集应用的指标,使用APM来监控应用并监督web服务的在线情况。源码可以在地址 https://github.com/liu-xiao-guo/java_observability 进行下载。摄入指标指标被视为可以随时更改的时间点值。当前请求的数量可以改变任何毫秒。你可能有1000个请求的峰值,然后一切都回到一个请求。这也意味着这些指标可能不准确,你还想提取最小/
HashMap中为什么引入红黑树,而不是AVL树呢1.概述开始学习这个知识点之前我们需要知道,在JDK1.8以及之前,针对HashMap有什么不同。JDK1.7的时候,HashMap的底层实现是数组+链表JDK1.8的时候,HashMap的底层实现是数组+链表+红黑树我们要思考一个问题,为什么要从链表转为红黑树呢。首先先让我们了解下链表有什么不好???2.链表上述的截图其实就是链表的结构,我们来看下链表的增删改查的时间复杂度增:因为链表不是线性结构,所以每次添加的时候,只需要移动一个节点,所以可以理解为复杂度是N(1)删:算法时间复杂度跟增保持一致查:既然是非线性结构,所以查询某一个节点的时候
SPI接收数据左移一位问题目录SPI接收数据左移一位问题一、问题描述二、问题分析三、探究原理四、经验总结最近在工作在学习调试SPI的过程中遇到一个问题——接收数据整体向左移了一位(1bit)。SPI数据收发是数据交换,因此接收数据时从第二个字节开始才是有效数据,也就是数据整体向右移一个字节(1byte)。请教前辈之后也没有得到解决,通过在网上查阅前人经验终于解决问题,所以写一个避坑经验总结。实际背景:MCU与一款芯片使用spi通信,MCU作为主机,芯片作为从机。这款芯片采用的是它规定的六线SPI,多了两根线:RDY和INT,这样从机就可以主动请求主机给主机发送数据了。一、问题描述根据从机芯片手