Tag Archives: xml

Maven of springboot project pom.xml Unknown error in the first line of the file

Reason: the plug-in version of Maven is not compatible with IDE

Solution: add & lt; Maven jar to POM- plugin.version&gt ;3.1.1</maven-jar- plugin.version&gt That’s all

    <properties>
        < java.version&gt ;1.8         <spring- cloud.version&gt ; Greenwich.SR1&lt ;/spring- cloud.version&gt ;
        <maven-jar- plugin.version&gt ;3.1.1</maven-jar- plugin.version&gt ;
    </properties>

After eclipse eclipse eclipse imports the correct project, an error is reported in XML and other files

I use eclipse ide to import a correct project. Some XML configuration files and JSP pages report errors. Click in to view the specific errors. XML files report errors in some header files, and JSP functions. But others did not report mistakes.

This is because the files we wrote are not written in strict accordance with the relevant rules of J2EE, but the operation will not make mistakes, as long as we do not let the project configuration select these.

resolvent:

Step 1: Project Explorer (if you don’t have this window, you can select an inverted triangle sign in the eclipse toolbar – & gt; window – & gt; show view – & gt; Project Explorer) – & gt; select the customize view (as shown in Figure 1) – & gt; content tab – & gt; and remove some J2EE and the last option (as shown in Figure 2 – available customization).

Figure 1

Figure 2

Step 2: Eclipse toolbar – & gt; window – & gt; preferences – & gt; validation – & gt; click the “disable all” button – & gt; OK/apply (as shown in the figure)

Step 3: clean the project and rebuild it.

After eclipse Eclispe imports the correct project, XML appears

Original text: http://blog.csdn.net/u013147600/article/details/47102971

org.hibernate.MappingException: invalid override definition

Error in reverse generating entity class from database table using hibernate

14:46:04,104 ERROR org.hibernate.util.XMLHelper - Error parsing XML: XML InputStream(31) The content of element type "hibernate-reverse-engineering" must match "(schema-selection*,type-mapping?,table-filter*,table*)".
14:46:04,107 ERROR org.hibernate.cfg.reveng.OverrideRepository - Could not configure overrides from file: E:\zxworkspace\src\main\resources\reveng.xml
org.hibernate.MappingException: invalid override definition
	at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:143)
	at org.hibernate.cfg.reveng.OverrideRepository.addFile(OverrideRepository.java:110)
	at org.codehaus.mojo.hibernate3.configuration.JDBCComponentConfiguration.loadRevengFile(JDBCComponentConfiguration.java:86)
	at org.codehaus.mojo.hibernate3.configuration.JDBCComponentConfiguration.doConfiguration(JDBCComponentConfiguration.java:40)
	at org.codehaus.mojo.hibernate3.configuration.AbstractComponentConfiguration.getConfiguration(AbstractComponentConfiguration.java:56)
	at org.codehaus.mojo.hibernate3.HibernateExporterMojo.configureExporter(HibernateExporterMojo.java:200)
	at org.codehaus.mojo.hibernate3.exporter.Hbm2JavaGeneratorMojo.configureExporter(Hbm2JavaGeneratorMojo.java:64)
	at org.codehaus.mojo.hibernate3.HibernateExporterMojo.doExecute(HibernateExporterMojo.java:273)
	at org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:152)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	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 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.xml.sax.SAXParseException; lineNumber: 31; columnNumber: 33; The content of element type "hibernate-reverse-engineering" must match "(schema-selection*,type-mapping?,table-filter*,table*)".
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
	at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.dom4j.io.SAXReader.read(SAXReader.java:465)
	at org.hibernate.cfg.reveng.OverrideRepository.addInputStream(OverrideRepository.java:142)
	... 29 more

My reason for reporting an error: I used to have two classes with entity classes, and then I was still generating them. After that, I deleted the configuration of these two reverse generated classes, and only configured those that had not been generated

I didn’t confirm whether there was a problem with the class before or my configuration. I checked my configuration many times, but I didn’t find any problem. I’ll follow up if I encounter it next time.

Solutions to errors in XML files

XML files in a project often report errors for no reason, but it does not affect the running of the program, which is really intolerable to people like me, so I searched online, I can turn off the validation of XML, and it will not report errors again. The operation is as follows: Window — Preferences — Validation, as shown in the figure

PS: Also, if you have similar validation errors for other types of files, you can remove the validation for the corresponding file type. At the same time, in order to improve the startup and compilation speed of the project, you can remove the validation of some files appropriately.

[Java] spring transaction control configuration error, application- persstence.xml Transaction manager report red in file

A, problem,
When configuring the Spring persistence layer XML configuration file, < tx:annotation-driven> ansaction-manager a>bute is always red, obviously there is a problem;

Second, the solution
1. Simply add to the configuration file:

xmlns:tx="
http://www.springframework.org/schema/cache"
xmlns:tx="http://www.springframework.org/schema/tx"

Configuration information;


=
=
=
=

Configuration error in mybatis configuration file

Development in mybatis mybatis project – config. After adding elements in the XML, found in the XML configuration label error: before and after the content for an error & lt; properties& gt; settings& gt; typeAliases& gt; typeHandlers& gt; objectFactory& gt; objectWrapperFactory& . >
Then find the answer in a development tool:
& lt; configuration> The child elements of the must follow: <<; properties> & lt; settings> & lt; typeAliases> & lt; typeHandlers> & lt; objectFactory> & lt; plugins>                                                                                                                                  & lt; enviroments>      & lt; databaseIdProvider>                                                               & lt; mappers>   In that order. Otherwise, MyBatis will report an error when parsing XML.

Meven report error java.lang.NoSuchMethodError : com.google.common . base.Preconditions.checkArgument

java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument
this error is that jar jar dependency conflicts need to remove duplicate dependencies

step 1: locate the jar where the class is located
IDEA quick search CTRL +c double click shift
locate the version to be deleted
locate the jar location of the specific class
then add the remove operation
in the pom file

Golong based tool for automatically generating the corresponding struct file according to XML file

By reading in an XML file, the corresponding struct is automatically generated and saved in the specified file.
XmlLoader. Go and xmlNodeStructCreator. Go are the following two files.
XmlLoader. Go parses the XML into a chained structured data. XmlNodeStructCreator. Go recursively extracts node information from the chained structured data and generates the corresponding structure file of the XML.
This is rough, especially the naming of field in the structure, which is directly named after the node. Interested friends can change it by themselves.
In addition, the Repository contains two other widgets that you may be interested in viewing.
Tool source code

SQL Error: 904, SQLState: 42000

Question:

WARN 2011-03-04 09:33:18 org.hibernate.util.JDBCExceptionReporter – SQL Error: 904, SQLState: 42000

the ERROR 2011-03-04 09:33:18 org. Hibernate. Util. JDBCExceptionReporter – ORA – 00904: “MENU0_”. “MENU_OPEN_IN_HOME” : identifier is invalid

Hibernate: select portletloc0_.PORTLET_LOCATION_ROW as col_0_0_, portletloc0_.PORTLET_LOCATION_COLUMN as col_1_0_, portlet1_.PORTLET_URL as col_2_0_, portlet1_.PORTLET_TITLE as col_3_0_, portletloc0_.PORTLET_ID as col_4_0_ from JEDA_PORTLET_LOCATION portletloc0_, JEDA_PORTLET portlet1_ where portletloc0_.PORTLET_ID=portlet1_.PORTLET_ID and portletloc0_.POSITION_ID=?order by portletloc0_.PORTLET_LOCATION_ROW asc, portletloc0_.PORTLET_LOCATION_COLUMN asc

2011-3-4 9:33:18 org.apache.catalina.core.StandardWrapperValve invoke

severity: servlet.service () for Servlet DispatcherServlet threw exception

java.sqlexception: “MENU0_”.”MENU_OPEN_IN_HOME”: identifier is invalid

the reason:
The attribute name of the
hbm. XML file does not correspond to the attribute name of the database

Spring boot can’t scan XML (invalid bound statement (not found))

in a recent work on a project, a headache problem, the background and foreground, after a successful start in obtaining some mapper, always show can not find the mapper, but if use Ctrl or can enter this method, on the Internet to find a lot of solutions, did not solve my problem, the following are some of the common rule out way:

1, check whether namespace in your XML file is correct

2. Check whether the mapper method written by yourself is consistent or missing with the method in XML, and whether the return type or name is consistent

3. If it is not possible yet, take a look to see if the XML configuration path of mapper is correct

4. Delete some Spaces in XML

5, I encountered myself, to see if the target file exists and is a level 1 directory:

, if you’re like me, you can delete the new mapper, and when you create a new mapper, you can create a new mapper, and you can create a new directory on the mapper.

and finally the target should look like this:

is just like that.

if not solved, you can leave a message to communicate with oh ~

Python parses XML files (parses, updates, writes)

Overview

This blog post will include parsing the XML file, appending new elements to write to the XML, and updating the value of a node in the original XML file. The python xml.dom.minidom package is used, and the details can be seen in its official document: xml.dom.minidom official document. The full text will operate around the following customer.xml :

<?xml version="1.0" encoding="utf-8" ?>
<!-- This is list of customers -->
<customers>
  <customer ID="C001">
    <name>Acme Inc.</name>
    <phone>12345</phone>
    <comments>
      <![CDATA[Regular customer since 1995]]>
    </comments>
  </customer>
  <customer ID="C002">
    <name>Star Wars Inc.</name>
    <phone>23456</phone>
    <comments>
      <![CDATA[A small but healthy company.]]>
    </comments>
  </customer>
</customers>

CDATA: part of the data in XML that is not parsed by the parser.

declaration: in this article, nodes and nodes are considered to be the same concept, you can replace them anywhere in the whole text, I personally feel the difference is not very big, of course, you can also view it as my typing error.

1. Parse XML file

when parsing XML, all text is stored in a text node, and the text nodes are regarded as nodes child elements, such as: 2005, element nodes, has a text node value is “2005”, “2005” is not the value of the element, the most commonly used method is the getElementsByTagName () method, and then further access to the nodes according to the document structure parsing.

specific theory is not enough to describe, with the above XML file and the following code, you will clearly see the operation method, the following code is to perform all node names and node information output as follows:

# -*- coding: utf-8 -*-
"""
    @Author  : LiuZhian
    @Time    : 2019/4/24 0024 上午 9:19
    @Comment : 
"""
from xml.dom.minidom import parse
def readXML():
	domTree = parse("./customer.xml")
	# 文档根元素
	rootNode = domTree.documentElement
	print(rootNode.nodeName)

	# 所有顾客
	customers = rootNode.getElementsByTagName("customer")
	print("****所有顾客信息****")
	for customer in customers:
		if customer.hasAttribute("ID"):
			print("ID:", customer.getAttribute("ID"))
			# name 元素
			name = customer.getElementsByTagName("name")[0]
			print(name.nodeName, ":", name.childNodes[0].data)
			# phone 元素
			phone = customer.getElementsByTagName("phone")[0]
			print(phone.nodeName, ":", phone.childNodes[0].data)
			# comments 元素
			comments = customer.getElementsByTagName("comments")[0]
			print(comments.nodeName, ":", comments.childNodes[0].data)

if __name__ == '__main__':
	readXML()

2. Write to XML file When writing

, I think there are two ways:

Create a new XML file

  • and append some element information to the existing XML file
  • in both cases, the method for creating element nodes is similar, all you have to do is create/get a DOM object, and then create a new node based on the DOM.

    in the first case, you can create it by dom= minidom.document (); In the second case, you can get the dom object directly by parsing the existing XML file, for example dom = parse("./customer.xml")

    when creating element/text nodes, you’ll probably write a four-step sequence like this:

  • create a new element node createElement()
  • create a text node createTextNode()
  • mount the text node on the element node
  • mount the element node on its parent.
  • now, I need to create a new customer node with the following information :

    <customer ID="C003">
        <name>kavin</name>
        <phone>32467</phone>
        <comments>
          <![CDATA[A small but healthy company.]]>
        </comments>
      </customer>
    

    code as follows:

    def writeXML():
    	domTree = parse("./customer.xml")
    	# 文档根元素
    	rootNode = domTree.documentElement
    
    	# 新建一个customer节点
    	customer_node = domTree.createElement("customer")
    	customer_node.setAttribute("ID", "C003")
    
    	# 创建name节点,并设置textValue
    	name_node = domTree.createElement("name")
    	name_text_value = domTree.createTextNode("kavin")
    	name_node.appendChild(name_text_value)  # 把文本节点挂到name_node节点
    	customer_node.appendChild(name_node)
    
    	# 创建phone节点,并设置textValue
    	phone_node = domTree.createElement("phone")
    	phone_text_value = domTree.createTextNode("32467")
    	phone_node.appendChild(phone_text_value)  # 把文本节点挂到name_node节点
    	customer_node.appendChild(phone_node)
    
    	# 创建comments节点,这里是CDATA
    	comments_node = domTree.createElement("comments")
    	cdata_text_value = domTree.createCDATASection("A small but healthy company.")
    	comments_node.appendChild(cdata_text_value)
    	customer_node.appendChild(comments_node)
    
    	rootNode.appendChild(customer_node)
    
    	with open('added_customer.xml', 'w') as f:
    		# 缩进 - 换行 - 编码
    		domTree.writexml(f, addindent='  ', encoding='utf-8')
    
    if __name__ == '__main__':
    	writeXML()
    

    3. Update XML file

    when updating XML, we only need to find the corresponding element node first, and then update the value of the text node or attribute under it, and then save it to the file. I will not say more about the details, but I have made the idea clear in the code, as follows:

    def updateXML():
    	domTree = parse("./customer.xml")
    	# 文档根元素
    	rootNode = domTree.documentElement
    
    	names = rootNode.getElementsByTagName("name")
    	for name in names:
    		if name.childNodes[0].data == "Acme Inc.":
    			# 获取到name节点的父节点
    			pn = name.parentNode
    			# 父节点的phone节点,其实也就是name的兄弟节点
    			# 可能有sibNode方法,我没试过,大家可以google一下
    			phone = pn.getElementsByTagName("phone")[0]
    			# 更新phone的取值
    			phone.childNodes[0].data = 99999
    
    	with open('updated_customer.xml', 'w') as f:
    		# 缩进 - 换行 - 编码
    		domTree.writexml(f, addindent='  ', encoding='utf-8')
    
    if __name__ == '__main__':
    	updateXML()
    

    if there is anything wrong, please advise ~