错误:
 Build error for /eid-generator/pom.xml; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate (Generate MyBatis Artifacts) on project eid-generator: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eid</groupId>
<artifactId>eid</artifactId>
<version>1.0.0</version>
</parent>
<groupId>eid-generator</groupId>
<artifactId>eid-generator</artifactId>
<packaging>jar</packaging>
<name>eid-generator</name>
<description>****平台-源码生成工具</description> <dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${version.mysql}</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>${version.mybatis-generator}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${version.mybatis}</version>
</dependency>
</dependencies> <build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*Mapper.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${version.jdk}</source>
<target>${version.jdk}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>${version.mybatis-generator}</version>
<configuration>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>${version.mybatis-generator}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${version.mysql}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${version.mybatis}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
copy-dependency plugin
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
<goal>resources</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<!-- 忽略该版本及其以上的版本的检查 -->
<versionRange>[${version.mybatis-generator},)</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

generatorConfig.xml代码:

<?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>
<classPathEntry
location="G:\java\eclipse-jee-indigo-SR2-win32-x86_64\apache-maven-3.3.9\mavenFactory\respo\mysql\mysql-connector-java\5.1.21\mysql-connector-java-5.1.21.jar" />
<context id="mysqlTables" targetRuntime="MyBatis3"
defaultModelType="flat"> <commentGenerator>
<property name="suppressDate" value="true" />
<property name="suppressAllComments" value="true"/>
</commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://115.28.13.4:3306/eiddb" userId="root"
password="****">
</jdbcConnection> <!-- false:把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true :把JDBC DECIMAL 和 
NUMERIC 类型解析为 java.math.BigDecimal -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver> <javaModelGenerator targetPackage="com.jjrt.eid.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 targetPackage="com.jjrt.eid.mapper"
type="XMLMAPPER" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator> <table tableName="ap_info" domainObjectName="apInfoBean"
enableCountByExample="false" 
enableUpdateByExample="false"
enableDeleteByExample="false" 
enableSelectByExample="false"
selectByExampleQueryId="false" /> </context>
</generatorConfiguration>

解决方案 »

  1.   

    建议检查一下连接配置。
    <plugin>
    <!--Mybatis-generator插件,用于自动生成Mapper和POJO-->
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-maven-plugin</artifactId>
    <version>1.3.2</version>
    <configuration>
    <!--配置文件的位置-->
    <configurationFile>D:/工作/代码/happyRec/src/main/resources/mybatis-generator-config.xml</configurationFile>
    <verbose>true</verbose>
    <overwrite>true</overwrite>
    </configuration>
    <executions>
    <execution>
    <id>Generate MyBatis Artifacts</id>
    <goals>
    <goal>generate</goal>
    </goals>
    </execution>
    </executions>红色字体部分如果配置错了,或者不是本项目下的文件,generate是不会去连接数据库的。