最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

在SpringBoot項(xiàng)目中利用maven的generate插件

 更新時(shí)間:2019年01月03日 09:48:33   作者:staHuri  
今天小編就為大家分享一篇關(guān)于在SpringBoot項(xiàng)目中利用maven的generate插件,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧

使用maven 插件 generate生成MyBatis相關(guān)文件

在項(xiàng)目中增加 maven 依賴

  1. - mybatis-spring-boot-starter
  2. - mysql-connector-java
  3. - mybatis-generator-maven-plugin 插件 自動(dòng)讀取 resources 下的generatorConfig.xml 文件
<?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.wangSpringBoot</groupId>
  <artifactId>demo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>demo</name>
  <description>Demo project for Spring Boot</description>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>
  <dependencies>
    <dependency>
<groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
<groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.16.18</version>
      <scope>provided</scope>
    </dependency>
    <!--熱部署-->
    <dependency>
<groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <optional>true</optional>
    </dependency>
    <!--test-->
    <dependency>
<groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <!--MyBatis-->
    <dependency>
<groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>1.3.1</version>
    </dependency>
    <!--Mysql JDBC驅(qū)動(dòng)-->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
<groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <fork>true</fork>
        </configuration>
      </plugin>
      <plugin>
<groupId>org.mybatis.generator</groupId>
        <artifactId>mybatis-generator-maven-plugin</artifactId>
        <version>1.3.7</version>
        <executions>
          <execution>
            <id>Generate MyBatis Artifacts</id>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
            <version>2.3.4</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>
      <resource>
<directory>src/main/resources</directory>
        <includes>
          <include>**/*.*</include>
        </includes>
      </resource>
      <resource>
<directory>src/main/webapp</directory>
        <targetPath>META-INF/resources</targetPath>
        <includes>
          <include>**/*.*</include>
        </includes>
      </resource>
    </resources>
  </build>
</project>

SpringBoot 項(xiàng)目中application.properties 配置

  • mybatis.mapper-locations 用來(lái)指定mapper 存放路徑
  • spring.datasource.username 用來(lái)指定 用戶名
  • spring.datasource.password 用來(lái)指定密碼
  • spring.datasource.driver-class-name 用來(lái)指定鏈接驅(qū)動(dòng)
  • spring.datasource.url 用來(lái)指定鏈接路由地址
mybatis.mapper-locations=classpath:com/wangspringboot/demo/mapper/*.xml
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/wt?useUnicode=true&characterEncoding=utf8&useSSL=false

resources 下配置 generatorConfig.xml

此項(xiàng)內(nèi)容為直接修改相關(guān)配置即可

<?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>
  <!-- 本地?cái)?shù)據(jù)庫(kù)驅(qū)動(dòng)程序jar包的全路徑 -->
  <classPathEntry
      location="D:\Program Files\MavenRepository\mysql\mysql-connector-java\5.1.46\mysql-connector-java-5.1.46.jar"/>
  <context id="context" targetRuntime="MyBatis3">
    <commentGenerator>
      <property name="suppressAllComments" value="false"/>
      <property name="suppressDate" value="true"/>
    </commentGenerator>
    <!-- 數(shù)據(jù)庫(kù)的相關(guān)配置 -->
    <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/wt" userId="root"
            password="root"/>
    <javaTypeResolver>
      <property name="forceBigDecimals" value="false"/>
    </javaTypeResolver>
    <!-- 實(shí)體類(lèi)生成的位置 -->
    <javaModelGenerator targetPackage="com.wangspringboot.demo.model" targetProject="src/main/java">
      <property name="enableSubPackages" value="false"/>
      <property name="trimStrings" value="true"/>
    </javaModelGenerator>
    <!-- *Mapper.xml 文件的位置 -->
    <sqlMapGenerator targetPackage="com.wangspringboot.demo.mapper" targetProject="src/main/java">
      <property name="enableSubPackages" value="false"/>
    </sqlMapGenerator>
    <!-- Mapper 接口文件的位置 -->
    <javaClientGenerator targetPackage="com.wangspringboot.demo.mapper" targetProject="src/main/java"
               type="XMLMAPPER">
      <property name="enableSubPackages" value="false"/>
    </javaClientGenerator>
    <!-- 相關(guān)表的配置-->
    <table tableName="t"
        domainObjectName="Tq"
        enableCountByExample="false"
        enableUpdateByExample="false"
        enableDeleteByExample="false"
        enableSelectByExample="false"
        selectByExampleQueryId="false"
    />
  </context>
</generatorConfiguration>

創(chuàng)建相關(guān)目錄

查看插件

執(zhí)行

選中maven 下 generator 雙擊運(yùn)行

SpringBootMyBatis 使用

在 service 的實(shí)現(xiàn)類(lèi)上添加 @Service 注解

@Service
public class TqServiceImpl implements TqService {
  @Autowired
  private TqMapper tqmapper;
  @Override
  public Tq insTq() {
    Tq t = new Tq();
    t.setZ(12.0);
    t.setY(12.0);
    t.setX(12.0);
    tqmapper.insert(t);
    return t;
  }
}

相關(guān)調(diào)用

@RestController
public class MyBatisController {
  @Autowired
  private TqService tqService;
  @GetMapping("/boot/tq")
  public Object tq(){
    return tqService.insTq();
  }
}

啟動(dòng)SpringBoot WEB項(xiàng)目后 訪問(wèn)

{
x: 12,
y: 12,
z: 12
}

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

相關(guān)文章

  • Java利用Sping框架編寫(xiě)RPC遠(yuǎn)程過(guò)程調(diào)用服務(wù)的教程

    Java利用Sping框架編寫(xiě)RPC遠(yuǎn)程過(guò)程調(diào)用服務(wù)的教程

    這篇文章主要介紹了Java利用Sping框架編寫(xiě)RPC遠(yuǎn)程過(guò)程調(diào)用服務(wù)的教程,包括項(xiàng)目管理工具M(jìn)aven的搭配使用方法,需要的朋友可以參考下
    2016-06-06
  • 使用Spring自身提供的地址匹配工具匹配URL操作

    使用Spring自身提供的地址匹配工具匹配URL操作

    這篇文章主要介紹了使用Spring自身提供的地址匹配工具匹配URL操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • MyBatis分頁(yè)查詢返回list的時(shí)候出現(xiàn)null的問(wèn)題

    MyBatis分頁(yè)查詢返回list的時(shí)候出現(xiàn)null的問(wèn)題

    這篇文章主要介紹了MyBatis分頁(yè)查詢返回list的時(shí)候出現(xiàn)null的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-07-07
  • Spring Boot Web 靜態(tài)文件緩存處理的方法

    Spring Boot Web 靜態(tài)文件緩存處理的方法

    本篇文章主要介紹了Spring Boot Web 靜態(tài)文件緩存處理的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-02-02
  • 聊聊Spring Cloud Cli 初體驗(yàn)

    聊聊Spring Cloud Cli 初體驗(yàn)

    這篇文章主要介紹了聊聊Spring Cloud Cli 初體驗(yàn),SpringBoot CLI 是spring Boot項(xiàng)目的腳手架工具。非常具有實(shí)用價(jià)值,需要的朋友可以參考下
    2018-04-04
  • Java詳細(xì)講解IO流的Writer與Reader操作

    Java詳細(xì)講解IO流的Writer與Reader操作

    Writer與Reader類(lèi)不能直接調(diào)用,需要使用多帶的方法調(diào)用它們的子類(lèi),在他們的前邊加上一個(gè)File即可如(FileWriter或FileReader)的多態(tài)方法進(jìn)行其調(diào)用,并且他們也是抽象類(lèi)調(diào)用需要連接接口Exception,它們的優(yōu)點(diǎn)在于可以直接寫(xiě)入或讀出內(nèi)容,不需要使用byte轉(zhuǎn)八進(jìn)制
    2022-05-05
  • spring接口通過(guò)配置支持返回多種格式(xml,json,html,excel)

    spring接口通過(guò)配置支持返回多種格式(xml,json,html,excel)

    這篇文章主要給大家介紹了關(guān)于spring接口如何通過(guò)配置支持返回多種格式(xml,json,html,excel)的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-12-12
  • Java e.printStackTrace()案例講解

    Java e.printStackTrace()案例講解

    這篇文章主要介紹了Java e.printStackTrace()案例講解,本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • 如何利用IDEA快速生成實(shí)體類(lèi)

    如何利用IDEA快速生成實(shí)體類(lèi)

    這篇文章主要介紹了如何利用IDEA快速生成實(shí)體類(lèi)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • SpringBoot API接口超時(shí)時(shí)間的五種配置方式詳解

    SpringBoot API接口超時(shí)時(shí)間的五種配置方式詳解

    在開(kāi)發(fā)API接口時(shí),配置API接口的超時(shí)時(shí)間是一項(xiàng)非常重要的任務(wù),SpringBoot中有多種方式可以配置API接口的超時(shí)時(shí)間,下面小編就為大家介紹一下吧
    2025-03-03

最新評(píng)論

姜堰市| 夏邑县| 陆丰市| 祁门县| 施秉县| 阿拉善右旗| 江安县| 涞源县| 弥渡县| 读书| 长顺县| 泾川县| 金平| 云阳县| 武山县| 新龙县| 塔城市| 青岛市| 海门市| 永平县| 长丰县| 长海县| 思南县| 博客| 定西市| 安岳县| 吕梁市| 贺兰县| 贵阳市| 通榆县| 虞城县| 岚皋县| 新泰市| 肥乡县| 甘泉县| 樟树市| 重庆市| 文成县| 思茅市| 中西区| 新营市|