Open dimetil810 opened 1 year ago
/resources直下に以下ファイルを配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<context id="MySQLTables" targetRuntime="MyBatis3">
<plugin type="org.mybatis.generator.plugins.MapperAnnotationPlugin"/>
<commentGenerator>
<property name="suppressDate" value="true"/>
<property name="suppressAllComments" value="false"/>
</commentGenerator>
<!-- DB接続情報:各自の環境に合わせて編集して使う-->
<jdbcConnection driverClass="org.postgresql"
connectionURL="jdbc:mysql://localhost:33306/"
userId="root"
password="developer">
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
<javaModelGenerator targetPackage="java.com.exsample.exsample.model" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="java.com.exsample.exsample.mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<javaClientGenerator targetPackage="java.com.exsample.exsample.mapper" targetProject="src/main/java"
type="MIXEDMAPPER">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="%"
enableInsert="true"
enableSelectByPrimaryKey="true"
enableSelectByExample="true"
enableUpdateByPrimaryKey="true"
enableUpdateByExample="true"
enableDeleteByPrimaryKey="true"
enableDeleteByExample="true"
enableCountByExample="true"
selectByExampleQueryId="true"
modelType="flat">
<property name="useActualColumnNames" value="false"/>
</table>
</context>
</generatorConfiguration>
MyBatis Generatorがなぜか動かないため、一旦手動でMapperを作成するとよさそう
https://qiita.com/TaikiTkwkbysh/items/9f598ed01c363b59fd98
PostgresSQLで権限を追加する
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA schema_name TO user_name;
PostgresSQLでsequenceの権限を追加する
GRANT USAGE, SELECT ON SEQUENCE sequence_name TO user_name;
pom.xmlのpluginsに以下を追記