Open source software supply chain lighting plan, waiting for you>>>
Today, we have a problem. The picture above is
This code is mainly to add a watermark to the image
Later Baidu found that there may be a problem with the path of the picture, because it is a dynamic image address, and then I printed out the address
After checking through the terminal, it was not
Then I found the file in the classes directory
At this time, he realized
Because my picture file was put in the Resources folder of the main folder at the beginning, it will be put in the classes folder when the file is compiled
However, my test code runs in the test folder, and the contents of the Resources folder in the test folder will be placed in the test classes folder
The dynamic path in the code is based on the current running code location, so the path is/users/Huang/ideaprojects/o2o/target/test classes/watermark.png, but the picture is compiled and placed in/users/Huang/ideaprojects/o2o/target/classes/watermark.png, so the error is reported and the file cannot be found
Solution:
I used a rough way to copy the image to test/resources. When compiling, the image will be put in the path of/users/Huang/ideaprojects/o2o/target/test classes. The problem is solved
Similar Posts:
- [Node.js] fs.renameSync() Error: Error: ENOENT: no such file or directory, rename…
- Logback: solve the problem that logback.xml configuration doesn’t work
- [Solved] JAVA Beginners’ Error: Exception in thread “main“ java.io.FileNotFoundException
- Expected rbrace error encountered in DW
- AndroidStudio 3: How to Export Jar File
- java.lang.RuntimeException: Canvas: trying to draw too large(203212800bytes) bitmap.
- [Solved] Tensorflow TypeError: Fetch argument array has invalid type ‘numpy.ndarry’
- python: _tkinter.TclError: couldn’t recognize data in image file
- Can’t create resource output directory
- [Solved] Mybatis Error: Invalid bound statement (not found)