maven里配置mybaitsGenerator插件遇到的坑(主要还是maven和我家的垃圾网的坑)

镜像源的锅?

1.一旦下载spring相关的一些jar包(之前做下载spark相关的包好像也遇到过类似的问题),本机上阿里云镜像源就不好使了,将镜像换为华为云或者其他一般就行了,不过这次还是不好使,我参考了最后一种方法,总算能够下载大多数jar包了(当时主要是org.mybatis.spring.boot下不下来)。
贴一波我现在好使的镜像源:

<mirror>
          <id>nexus</id>
          <name>internal nexus repository</name>
          <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
          <url>https://repo.maven.apache.org/maven2</url>
          <mirrorOf>central</mirrorOf>
      </mirror>
      <mirror>
          <id>huaweicloud</id>
          <mirrorOf>*</mirrorOf>
          <url>https://mirrors.huaweicloud.com/repository/maven/</url>
      </mirror>



        <mirror>
            <id>jboss-public-repository-group</id>
            <mirrorOf>central</mirrorOf>
            <name>JBoss Public Repository Group</name>
            <url>http://repository.jboss.org/nexus/content/groups/public</url>
        </mirror>
        <mirror>
            <id>google-maven-central</id>
            <name>Google Maven Central</name>
            <url>https://maven-central.storage.googleapis.com
            </url>
            <mirrorOf>central</mirrorOf>
        </mirror>
        <!-- 中央仓库在中国的镜像 -->
        <mirror>
            <id>maven.net.cn</id>
            <name>oneof the central mirrors in china</name>
            <url>http://maven.net.cn/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>

org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available

然后出现了一个插件或者包死活下不下来,我参考了最佳回答,从获取项目自己打包
,然后出现了无效的目标发行版,这个问题是因为JDK版本与MAVEN版本不一致导致的,
由于我主要使用jdk11,所以干脆将maven的settings.xml直接配置为11得了,省得每次都要写。


  </profiles>
	<profile>
      <id>jdk-1.11</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>11</jdk>
        </activation>
        <properties>
            <maven.compiler.source>11</maven.compiler.source>
            <maven.compiler.target>11</maven.compiler.target>
            <maven.compiler.compilerVersion>11</maven.compiler.compilerVersion>
        </properties>
    </profile>

  </profiles>

Downloading: http://repo.maven.apache.org/maven2/

发现还是在从官方源下载jar包,而我家的网速又比较…所以理所当然的没下下来。参考了高赞评论的回复。在pom文件中添加了如下内容,这时问题就解决了。

<repositories>
    <repository>
      <id>alimaven</id>
      <url>https://maven.aliyun.com/repository/public</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>alimaven</id>
      <url>https://maven.aliyun.com/repository/public</url>
    </pluginRepository>
  </pluginRepositories>

在这里插入图片描述
在这里插入图片描述

附加问题,不明原因

本来我其中的一个表的名称为为users,但是生成的实体类的结构不对,只含一个String类型的user字段和两个long类型的字段。与原表结构不符。
我将库中表名改为了user_info,这时再映射一遍,结构就对了。疑惑

pom文件

贴一下完整的pom文件,当然很多东西是不必要的,可以根据自己的情况删改。

<?xml version="1.0" encoding="UTF-8"?>

<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>

  <groupId>com.yuan.z</groupId>
  <artifactId>MSXM</artifactId>
  <version>1.0-SNAPSHOT</version>
  <repositories>
    <repository>
      <id>alimaven</id>
      <url>https://maven.aliyun.com/repository/public</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>alimaven</id>
      <url>https://maven.aliyun.com/repository/public</url>
    </pluginRepository>
  </pluginRepositories>
  <name>MSXM</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.4.RELEASE</version>
  </parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>8.0.16</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>1.1.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>1.3.2</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis.generator</groupId>
      <artifactId>mybatis-generator-core</artifactId>
      <version>1.3.5</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-autoconfigure -->
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-autoconfigure</artifactId>
      <version>1.3.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter-test -->
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter-test</artifactId>
      <version>1.3.2</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.mybatis.generator</groupId>
      <artifactId>mybatis-generator-core</artifactId>
      <version>1.3.5</version>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <groupId>org.mybatis.generator</groupId>
          <artifactId>mybatis-generator-maven-plugin</artifactId>
          <version>1.3.5</version>
          <dependencies>
            <dependency>
              <groupId>org.mybatis.generator</groupId>
              <artifactId>mybatis-generator-core</artifactId>
              <version>1.3.5</version>
            </dependency>

            <dependency>
              <groupId>mysql</groupId>
              <artifactId>mysql-connector-java</artifactId>
              <version>8.0.16</version>
            </dependency>
          </dependencies>
          <executions>
            <execution>
              <id>mybatis generator</id>
              <phase>package</phase>
              <goals>
                <goal>generate</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <configurationFile>
              src\main\resources\mybatis_generatorConfig.xml
            </configurationFile>
            <verbose>true</verbose>
            <overwrite>true</overwrite>


          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值