maven项目mybatis generator找不到mysql驱动

a1861706 2017-11-08 01:26:45
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.user</groupId>
<artifactId>test</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>SmartServer Maven Webapp</name>
<url>http://maven.apache.org</url>

<properties>
<spring.version>4.3.7.RELEASE</spring.version>
<mybatis.version>3.4.2</mybatis.version>
</properties>

<dependencies>
<!-- SpringMVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring-Jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- Spring aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.41</version>
</dependency>

<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

</dependencies>
<build>
<finalName>test</finalName>
</build>
</project>

mybatis generator配置文件
<?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="MySQL" targetRuntime="MyBatis3">

<jdbcConnection driverClass="com.jdbc.mysql.Driver"
connectionURL="jdbc:mysql://localhost:3306/user"
userId="root"
password="">
</jdbcConnection>

<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>

<javaModelGenerator targetPackage="com.user.bean"
targetProject=".\src\main\java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>

<sqlMapGenerator targetPackage="mapper" targetProject=".\src\main\resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>

<javaClientGenerator type="XMLMAPPER"
targetPackage="com.user.dao" targetProject=".\src\main\java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>

<table tableName="user" domainObjectName="User"></table>
</context>
</generatorConfiguration>






本人第一次用,一直找不到驱动,求助!
...全文
324 6 点赞 打赏 收藏 举报
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Sunyiban 2017-11-08
引用 5 楼 a1861706 的回复:
[quote=引用 4 楼 ylz2007 的回复:] 在mybatis generator配置文件中增加驱动配置(使用绝对路径): <classPathEntry location="D:/mysql-connector-java-5.1.42.jar" />
试过了还是不行,无论怎么弄都是 pom.xml中也已经把插件给添加了,还是不行[/quote] <!-- 配置生成器 --> <generatorConfiguration> <!-- 在MBG工作的时候,需要额外加载的依赖包,location属性指明加载jar/zip包的全路径 --> <classPathEntry location="D:/Maven/mysql/mysql-connector-java/5.1.39/mysql-connector-java-5.1.39.jar" /> 这么写试试
  • 打赏
  • 举报
回复
a1861706 2017-11-08
引用 4 楼 ylz2007 的回复:
在mybatis generator配置文件中增加驱动配置(使用绝对路径):
<classPathEntry
location="D:/mysql-connector-java-5.1.42.jar" />

试过了还是不行,无论怎么弄都是

pom.xml中也已经把插件给添加了,还是不行
  • 打赏
  • 举报
回复
在mybatis generator配置文件中增加驱动配置(使用绝对路径): <classPathEntry location="D:/mysql-connector-java-5.1.42.jar" />
  • 打赏
  • 举报
回复
a1861706 2017-11-08
Help!
  • 打赏
  • 举报
回复
a1861706 2017-11-08
引用 1 楼 l359122505 的回复:
目测没有引入jre,项目右键->properties->Java Build Path

有撒
  • 打赏
  • 举报
回复
目测没有引入jre,项目右键->properties->Java Build Path
  • 打赏
  • 举报
回复
相关推荐
发帖
Java EE
加入

6.7w+

社区成员

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
申请成为版主
帖子事件
创建了帖子
2017-11-08 01:26
社区公告
暂无公告