Reading files from SpringBoot resources folder

Reading files from a SpringBoot jar is something a little complex.

I had tried to read a file from springboot resources folder using This is the code:

And I got the FileNotFoundException :

Since there is no path like file:/data/www/htdocs/my-app/lib/my-app.jar!/BOOT-INF/class existed in my computer, I got the exception. Continue reading

Package all files in Java resources’ subdirectories

Maybe mvn clean package is one of the easiest operation in java programing. Howerver, I recently encountered a problem of packaging, which took up some of my time.

This was the initial package config in maven pom:

And this is the path of the file I wanted to package and read:

Executing the package command (mvn clean package) and opening the jar with compression software (e.g. WinRAR), the file was expected to locate at BOOT-INFO/class/template. However I could not find it. Though all files in resources folder directly existed, the others in subdirectories was not there. Continue reading

Markdown – Embedding Code Snippets In Code Snippet

When tried to show how to insert code snippets in markdown, I found that I didn’t know how to insert code sinppets in code snippet.

Helped by Google, I finally got the solution.

We can embed code snippets into Markdown text by:

  1. intending 4 or more spaces, or a tab as code block
  2. using triple backticks plus a syntax language code delimiter at the beginning and triple backticks at the end of code block

Interactive use of the two ways can help us write a demo of inserting code in markdown. Continue reading

How To Insert Code Snippets in Blogger Post

There’s no native way to insert codes in Blogger (ie – no button on the editor toolbar). However we can manage to overcome the problem.

The easiest way is to write the full content in markdown and then copy it into the blog editor. It comes with full syntax highlighting in the language of your choice.

For example, we can write java code like this:

And the result:

Continue reading

SpringBoot Mybatis Insert null Fields

I’m using SpringBoot and MyBatis. When tried to insert/update some rows into a table, I got the fllowing:

The column remark in the table user was setted to NOT NULL, and the value of the column to insert was null. That’s why I received the error. Continue reading

How to make Jackson to avoid Escaping Backslash

As I tried to deserialize a json string from database with jackson, I received error message like this:

The json string is:

It’s the Backslash in the source json string which lead to the error. Continue reading