我正在使用 sql-maven-plugin 在多个数据库上执行一些 MySQL 脚本。我想在同一个 SQL 脚本中部署表、数据、触发器、事件和存储过程。
我对行分隔符有疑问,因为对于 INSERT 或 CREATE 我使用;
,但对于我的触发器,我必须使用 更改分隔符DELIMITER //
,例如。
我知道该插件允许更改分隔符,但它适用于所有脚本,我只想为唯一脚本的一部分更改分隔符。
这是我的 Maven 配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>
</dependencies>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<username>${db.user}</username>
<password>${db.passwd}</password>
<encoding>UTF-8</encoding>
<orderFile>ascending</orderFile>
<keepFormat>true</keepFormat>
<driverProperties>characterEncoding=utf8,
connectionCollation=utf8_general_ci,
sql_mode=STRICT_TRANS_TABLES</driverProperties>
</configuration>
<executions>
<execution>
<id>execution-mysql</id>
<phase>prepare-package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>jdbc:mysql://${db.url}:${db.port}</url
<delimiterType>normal</delimiterType>
<fileset>
<basedir>${project.build.directory}/sql/</basedir>
<includes>
<include>${file.sql}</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>