<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                1.pom文件引入 ~~~ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!-- 測試 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- web組件 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version> </dependency> <!-- mysql依賴 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> </dependencies> ~~~ 2.配置文件引入 ~~~ spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/demo1 spring.datasource.username=root spring.datasource.password=root ~~~ 3.后臺代碼 ~~~ //UserMapper類 public interface UserMapper { //查詢語句 @Select("select * from user_t where username=#{username}") User findByName(@Param("username") String username); //添加 @Insert("insert into user_t(username,age) values(#{username},#{age})") int insert(@Param("username") String username,@Param("age") Integer age); } ~~~ ~~~ //UserService @Service public class UserService { @Autowired private UserMapper userMapper; public int insert(String username, Integer age){ int returnValue=userMapper.insert(username, age); return returnValue; } } ~~~ ~~~ @RestController public class UserController { @Autowired private UserService userService; @RequestMapping("/insertUser") public Integer insertUser(String username, Integer age){ return userService.insert(username, age); } } ~~~ ~~~ //啟動類 /*** * 1.mybatis啟動方式可以在mapper層不需要加mapper注解 但是一定要在啟動類加上@MapperScan * 2.mapper接口加了@Mapper,就在啟動類加上@MapperScan * @author Administrator * */ @SpringBootApplication //@MapperScan(basePackages={"cn.li.mapper"}) public class AppConfig { public static void main(String[] args) { SpringApplication.run(AppConfig.class, args); } } ~~~ 訪問http://localhost:8080/insertUser?username=zhangsan&age=20 可以看到數據庫中插入了一條數據 ![](https://box.kancloud.cn/54d1e3e375782efcf7bbc371fd1877bc_198x21.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看