这是我的插件配置:
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>0.7.3</version>
<dependencies>
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae.version}</version>
<type>pom</type>
</dependency>
</dependencies>
<configuration>
<jvmFlags>
<jvmFlag>-Drdbms.server=local</jvmFlag>
<jvmFlag>-Drdbms.driver=com.mysql.jdbc.Driver</jvmFlag>
<jvmFlag>-Drdbms.url=jdbc:mysql://localhost:3306/prova?user=root&password=pass</jvmFlag>
</jvmFlags>
<serverId>appengine.google.com</serverId>
</configuration>
</plugin>
您可以在此处阅读更多内容:https://developers.google.com/cloud-sql/docs/developers_guide_java
首先我做了这个微不足道的错误,做mvn gae:run
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
所以我将“真正的”驱动程序添加到我的pom.xml中:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
没有结果。错误保持不变。
stacktrace的一部分:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at com.google.appengine.tools.development.DevAppServerClassLoader.loadClass(DevAppServerClassLoader.java:87)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.google.appengine.api.rdbms.dev.LocalRdbmsServiceLocalDriver.registerDriver(LocalRdbmsServiceLocalDriver.java:84)
at com.google.appengine.api.rdbms.dev.LocalRdbmsServiceLocalDriver.init(LocalRdbmsServiceLocalDriver.java:73)
at com.google.appengine.api.rdbms.dev.LocalRdbmsService.init(LocalRdbmsService.java:85)
修改
我的新插件conf:
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>0.9.2</version>
<dependencies>
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
</dependencies>
<configuration>
<jvmFlags>
<jvmFlag>-Drdbms.server=local</jvmFlag>
<jvmFlag>-Drdbms.driver=com.mysql.jdbc.Driver</jvmFlag>
<jvmFlag>-Drdbms.url=jdbc:mysql://localhost:3306/prova?user=root&password=pass</jvmFlag>
</jvmFlags>
<serverId>appengine.google.com</serverId>
<!-- <sdkDir>${appengine.sdk.root}</sdkDir> -->
<!-- <appDir>${basedir}/war</appDir> -->
</configuration>
</plugin>
答案 0 :(得分:4)
好的,我解决了。我手动将mysql-connector-java-5.1.18-bin.jar
放入我的sdk文件夹中:
file:///opt/appengine-java-sdk-1.6.0/lib/impl/
错误更改更舒适:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
感谢您提出建议
答案 1 :(得分:2)
或者您可以使用maven-antrun-plugin在构建时为您执行此操作。不再为您的项目团队进行人工干预(我使用官方的appengine-maven-plugin,您需要调整使用maven-gae-plugin的路径):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<!-- Use 'package' instead of 'install' if you want the Driver to be available for 'integration-test' -->
<phase>package</phase>
<configuration>
<target>
<!-- delete existing mysql jar from appengine sdk lib/impl -->
<delete>
<fileset
dir="${settings.localRepository}/com/google/appengine/appengine-java-sdk/${appengine.target.version}/appengine-java-sdk/appengine-java-sdk-${appengine.target.version}/lib/impl"
includes="**/mysql-connector-java*" />
</delete>
<!-- copy mysql jar into appengine sdk lib/impl -->
<copy
file="${settings.localRepository}/mysql/mysql-connector-java/${mysql.version}/mysql-connector-java-${mysql.version}.jar"
todir="${settings.localRepository}/com/google/appengine/appengine-java-sdk/${appengine.target.version}/appengine-java-sdk/appengine-java-sdk-${appengine.target.version}/lib/impl"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
答案 2 :(得分:1)
您是否也将此添加到插件的依赖项中?
如果是插件的类路径,则应该由GAE选择。