Idea上搭建Springboot+mybatis+shiro

來源:互聯網
上載者:User

標籤:depend   localhost   data   lse   doc   username   使用   nbsp   mapping   

一:建立Project,Idea是一款功能很強大的軟體,有專門的產生springboot的外掛程式

有時候會遇到timeout連線逾時,將Defult預設的路徑改為自訂:http://start.spring.io點擊next

next

 

 

finish,等待idea自動構建架構

測試:

首先在applicationproperties檔案配置

spring.datasource.url = jdbc:mysql://localhost:3306/testspring.datasource.username = rootspring.datasource.password =  123456spring.datasource.driverClassName = com.mysql.jdbc.Driver#頁面熱載入spring.thymeleaf.cache = false#連接埠server.port=8888

  其次在靜態檔案夾static下建立test.css檔案

在templates下建立HTML檔案-hello.html

接下來寫controller

package com.example.demo.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;@Controllerpublic class indexController {    @RequestMapping("index")    public String index(){        return "hello";    }}

  

啟動程式,有兩種方法

啟動成功:

79606810(Mybatis入門)

 使用mybatis xml方式進行編寫配置

1.jar包支援

<!--mybatis核心包-->        <dependency>            <groupId>org.mybatis</groupId>            <artifactId>mybatis</artifactId>            <version>3.3.0</version>        </dependency>        <!--MySQL的JDBC驅動包-->        <dependency>            <groupId>mysql</groupId>            <artifactId>mysql-connector-java</artifactId>            <version>5.1.29</version>        </dependency>        <!--junit單元測試包-->        <dependency>            <groupId>junit</groupId>            <artifactId>junit</artifactId>            <version>4.12</version>        </dependency>

  2.xml配置

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE configuration        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"        "http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration>    <environments default="development">        <environment id="development">            <transactionManager type="JDBC"/>            <dataSource type="POOLED">                <property name="driver" value="com.mysql.jdbc.Driver"/>                <property name="url" value="jdbc:mysql://localhost:3306/mybatis"/>                <property name="username" value="root"/>                <property name="password" value="123"/>            </dataSource>        </environment>    </environments>    <mappers>        <mapper resource="mapper/Person.xml"/>    </mappers></configuration>

  

 https://www.cnblogs.com/-xuzhankun/p/6627424.html(參考包含springboot+mybatis  xml形式的搭建)

Idea上搭建Springboot+mybatis+shiro

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.