


How to solve the problem that resource files such as xml under src cannot be read in IDEA
The essence of the problem is the idea's regulations on classpath.
In eclipse, you can find the resource files by placing them in the src folder;
But in idea, you can directly place the resource files in the src folder. If you do not proceed Settings cannot be found.
Let’s talk about several solutions. Everything on the Internet is very confusing. Let me make a summary here: Recommended method 4
1. Place all resource files in the resources folder
This is very convenient and easier to think of, but the hierarchy is very poor. For example, the mapping configuration file mapper.xml of mybatis originally needs to be placed in a specific package, along with the dao layer, service layer, etc. The levels are at the same level. Now they can only be placed under the resource folder, which is inconvenient to layer;
2. If the project is a maven project:
Configure the maven pom file configuration, in Find the
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> </resources> </build>
I have tried changing the directory to a specific package where the configuration file is placed, that is, to src/main/java/lj/necpu/mapperXML , and then a lot of modifications and attempts were made in the
So, just use the configuration above; if you still cannot access, welcome to discuss; If you know how to modify it, please also discuss it in the thread, thank you~
3. Mark directory as... Resources:
right-click the package containing the configuration file. Click on the package-> Mark Directory As, you will find that there is only one exclude; what should I do?
Project Structure -> Modules -> Sources -> Select the package containing the configuration file -> Mark as -> Select the third Resources -> OK
4. Add package to classpath:
Project Struture -> Modules -> Dependencies -> "+" -> JARS or directories -> Select package
-> Pop-up Choose Categories of Selected Files -> Select Classes -> OK
The above methods can find resource files in the IDEA development environment, but whether the specific package and release will include the resource files requires specific testing.
My test result is that all 4 methods can include the xml file in the package when publishing.
The above is the detailed content of How to solve the problem that resource files such as xml under src cannot be read in IDEA. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The differences between IDEA Community Edition and Professional Edition include authorization methods, functions, support and updates, plug-in support, cloud services and team collaboration, mobile development support, education and learning, integration and scalability, error handling and debugging, security and privacy protection. etc. Detailed introduction: 1. Authorization method. The community version is free and suitable for all developers, no matter what operating system is used. The community version supports open source projects and commercial projects. The professional version is paid and suitable for commercial development. The professional version has 30 There is a trial period of three days, after which you need to purchase a license to continue using it, etc.

Can XML files be opened with PPT? XML, Extensible Markup Language (Extensible Markup Language), is a universal markup language that is widely used in data exchange and data storage. Compared with HTML, XML is more flexible and can define its own tags and data structures, making the storage and exchange of data more convenient and unified. PPT, or PowerPoint, is a software developed by Microsoft for creating presentations. It provides a comprehensive way of

How to handle XML and JSON data formats in C# development requires specific code examples. In modern software development, XML and JSON are two widely used data formats. XML (Extensible Markup Language) is a markup language used to store and transmit data, while JSON (JavaScript Object Notation) is a lightweight data exchange format. In C# development, we often need to process and operate XML and JSON data. This article will focus on how to use C# to process these two data formats, and attach

IDEA (IntelliJIDEA) is a powerful integrated development environment that can help developers develop various Java applications quickly and efficiently. In Java project development, using Maven as a project management tool can help us better manage dependent libraries, build projects, etc. This article will detail the basic steps on how to create a Maven project in IDEA, while providing specific code examples. Step 1: Open IDEA and create a new project Open IntelliJIDEA

Use PHPXML functions to process XML data: Parse XML data: simplexml_load_file() and simplexml_load_string() load XML files or strings. Access XML data: Use the properties and methods of the SimpleXML object to obtain element names, attribute values, and subelements. Modify XML data: add new elements and attributes using the addChild() and addAttribute() methods. Serialized XML data: The asXML() method converts a SimpleXML object into an XML string. Practical example: parse product feed XML, extract product information, transform and store it into a database.

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Configuration steps: 1. Open IntelliJ IDEA and enter the project; 2. Click "Run" in the top menu; 3. Select the plus sign in the upper left corner and select "Tomcat Server" > "Local"; 4. In the "Server" option, Click "Configure" and select the Tomcat installation directory; 5. In the "Deployment" option, click the plus sign to add your project; 6. Save it in "Before launch"

Jackson is a Java-based library that is useful for converting Java objects to JSON and JSON to Java objects. JacksonAPI is faster than other APIs, requires less memory area, and is suitable for large objects. We use the writeValueAsString() method of the XmlMapper class to convert the POJO to XML format, and the corresponding POJO instance needs to be passed as a parameter to this method. Syntax publicStringwriteValueAsString(Objectvalue)throwsJsonProcessingExceptionExampleimp
