


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

AI Hentai Generator
Generate AI Hentai for free.

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

Convert XML data in Python to CSV format XML (ExtensibleMarkupLanguage) is an extensible markup language commonly used for data storage and transmission. CSV (CommaSeparatedValues) is a comma-delimited text file format commonly used for data import and export. When processing data, sometimes it is necessary to convert XML data to CSV format for easy analysis and processing. Python is a powerful

src and href are respectively, 1. src is the abbreviation of source, which is used to specify the path of external resources. It is usually used to embed external files, such as pictures, audios, videos, etc. The src attribute is generally used on img, script, iframe and other tags. ; 2. href is the abbreviation of hypertext reference, which is used to specify the path of the target resource of the hyperlink. It is usually used to link to external documents or other pages. The href attribute is generally used on tags such as a and link.

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

Using Python to implement data validation in XML Introduction: In real life, we often deal with a variety of data, among which XML (Extensible Markup Language) is a commonly used data format. XML has good readability and scalability, and is widely used in various fields, such as data exchange, configuration files, etc. When processing XML data, we often need to verify the data to ensure the integrity and correctness of the data. This article will introduce how to use Python to implement data verification in XML and give the corresponding

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

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
