Solve the problem that when mybatis-generator generates the user table, it generates the user table that comes with mysql

Today I used mybatis-generator to generate the user table in the mysql database. I found that the generated table was different from what I actually wrote. Check the official documentation of mybatis-generator.

There is such a description in the mysql database information

If you are using version 8.x of Connector/J you may notice that the generator attempts to generate code for tables in the MySql information schemas (sys, information_schema, performance_schema, etc.) This is probably not what you want! To disable this behavior, add the property "nullCatalogMeansCurrent=true" to your JDBC URL.

 Translated as follows

If you are using the 8.x version of Connector/J, you may notice that the generator is trying to generate code for tables in the MySql information schema (sys, information_schema, performance_schema, etc.), which is probably not what you want! To disable this behavior, add the attribute "nullCatalogMeansCurrent=true" to the JDBC URL.

Note: If mysql8.x or above encounters a table name that is the same as the one that comes with mysql during generation, the code will be generated according to the table that comes with mysql. You need to configure a property attribute in the jdbcConnection tag.

That is as follows

<jdbcConnection 
            driverClass="com.mysql.cj.jdbc.Driver"                
            connectionURL="jdbc:mysql://localhost:3306/my_database"
            userId="my_user" 
            password="my_password">
        <property name="nullCatalogMeansCurrent" value="true" />
</jdbcConnection>

successfully solved

Guess you like

Origin blog.csdn.net/m0_54250110/article/details/129431418