2-5 Mybatis-Plus configuration file

Prepare something in advance.
logback.xml is the log xml


copied to common resources.

The first is the pom dependency, then the configuration file.


EntityGenerator is a code generator provided by Mybatis-plus. Generate controller, service, dao according to your table structure. In fact, we don't need controller and service. Here we only need dao. However



, the Druid used for the connection pool that it needs to generate is known as the best connection pool in China.






First copy this 

to our parent project. The

dependency configuration is in common, and then pass the maven dependency to other modules. This can achieve the purpose of one configuration and multiple use.
Copying these dependencies



here is just dependency management, so after writing it won't do you any dependency introduction.

So we introduce it again in common.

Then we can remove these versions.

We only introduce dependencies, and no version is needed. These versions are unified and managed by the parent project. '


If you do package updates in the future, you only need to change the version in the parent project. The submodule is naturally changed.

Introduce resources


Create a build node and import it.

In our normal package management, all of our configuration should be in the resources folder. The XML of the data layer should also be placed below this.


But I personally have a habit that the things in the data layer like to be put together with the data,
so we need to build DAO, data entities, and then the Mapper interface, as well as our xml, these three things we will put together . However, it is not recognized by default. This is a very disgusting thing for us.

So we write a resource here. He is the xml under our src / main / java mapped to src / main / resources. In this way, when packaging, by default, all XML under Java will be hit under resources.
In this way, xml can be written in our java directory. After writing, xml will be packaged into the resources folder after being packaged so that it can be recognized.



 

Import configuration file

Copy the prepared configuration file.


The logs of spring boot are all managed by logback.xml.

This is the data source.



Two stars represent any level of underground

* Mapper.xml to find any Mapper.xml. So the xml you write must be written as XXXMapper.xml, otherwise it will not be recognized.


 

End

 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/12677066.html