After compilation, the config.propertes configuration file is generated in the target/classes directory.
This configuration file is used in the A class in the code. The usage is as follows:
prop.load(Object.class.getResourceAsStream("/config.properties"));
The result has been reported a NULL error.
Print path view
System.out.println(Object.class.getResource("/"));
The result is NULL, and the print path
System.out.println(A.class.getResource("/"));
The result is target/classes/
Therefore, the statement that takes the attribute is replaced.
prop.load(A.class.getResourceAsStream("/config.properties"));
I wanted to implement music loop playback in a java application, but the return value of getResource("music/bg.wav") is null. I guess the path is a problem. I tried tryResource("/music/...
To avoid coupling code, DAO layer using the factory pattern is achieved. 1. Write a profile daoconfig.properties, here is my own employee of a table 2.DAO Interface: Define methods 3.DAO JDBC interfac...
Today, I used Spring to create a web project. I used Maven when I could create a Spring project. It is very convenient to use the Maven House. It is only a bug in today. Source code: Discover is jdbcu...
Returns NULL is the path error. After multiple attempts, use the following method to solve 1. Create an Assets folder, create a new config.properties file 2.config.properties file content 3. Create a ...
When learning a Web project, I encountered a simple problem and recorded the solution. I am taking a Java course from Dark Horse Programmer. The course was taken in May 2018. The current IDEA is a lit...
Regarding the question of class.getClassLoader().getResourceAsStream() is null under the Maven project Recently I used this method in a Java project. In the copy to library project, I found that the r...
always uses the LocationManager.getLastKnownLocation("gps") to get the gps location. Baidu checked a lot of information on the Internet and found that this problem appeared in version 2.0 or...
When I wrote the NIO program, I encountered the problem that the SelectionKey.attachment() was empty. Finally, I solved it. Here, I would like to help others: ...
background Today I wrote a UDF function to calculate the parameters of the fan interaction rate. When there is a video number, the interaction_sum is divided by the number of videos, otherwise divided...
Question code: Bitmap bmp = BitmapFactory.decodeResource(resources, R.drawable.ic_image); among them R.drawable.ic_image , this code is at4.4 Running fine, but in5.0 The above system will have a null ...