maven各种命令及插件的应用

说明:通过maven创建数据库

1、配置数据库连接信息
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<junit.version>4.10</junit.version>
		<mysql.driver>com.mysql.jdbc.Driver</mysql.driver>
		<mysql.url>jdbc:mysql://localhost:3306/mysql</mysql.url>
		<mysql.username>root</mysql.username>
		<mysql.password>root</mysql.password>
	</properties>

2、添加创建支持
				<!-- 连接数据库,并创建数据库 -->
				<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.18</version>
						</dependency>
					</dependencies>
					<configuration>
						<driver>${mysql.driver}</driver>
						<url>${mysql.url}</url>
						<username>${mysql.username}</username>
						<password>${mysql.password}</password>
						<sqlCommand>
							create database IF NOT EXISTS maven_test1
						</sqlCommand>
					</configuration>
					<!-- 绑定到什么命令后面 -->
					<executions>
						<execution>
							<phase>package</phase>
							<goals>
								<goal>execute</goal>
							</goals>
						</execution>
					</executions>
				</plugin>

你可能感兴趣的:(maven)