1 、配置pom.xml文件
官方参考:
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.0.8</version> </dependency> 2、配置boot.scala文件 DB.defineConnectionManager(DefaultConnectionIdentifier, DBVendor) 官方参考: object DBVendor extends ConnectionManager { def newConnection(name: ConnectionIdentifier): Box[Connection] = { try { Class.forName("com.mysql.jdbc.Driver") val dm = DriverManager.getConnection("jdbc:mysql://localhost/name-of-your-database?user=root&password=mysql-password") Full(dm) } catch { case e : Exception => e.printStackTrace; Empty } } def releaseConnection(conn: Connection) {conn.close} } import net.liftweb.mapper.{ConnectionManager,ConnectionIdentifier} import java.sql.{Connection, DriverManager}
参考网站:
http://wiki.liftweb.net/index.php/HowTo_configure_lift_with_MySQL