1.    新建Maven项目  spring-boot

2.    pom.xml

  1. <project xmlns="http://maven.apache.org/POM/4.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
  4. http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5.  
  6. <modelVersion>4.0.0</modelVersion>
  7. <groupId>com.java</groupId>
  8. <artifactId>spring-boot</artifactId>
  9. <version>1.0.0</version>
  10.  
  11. <parent>
  12. <groupId>org.springframework.boot</groupId>
  13. <artifactId>spring-boot-starter-parent</artifactId>
  14. <version>2.0.5.RELEASE</version>
  15. </parent>
  16.  
  17. <dependencies>
  18.  
  19. <!-- Spring Boot -->
  20. <dependency>
  21. <groupId>org.springframework.boot</groupId>
  22. <artifactId>spring-boot-starter-web</artifactId>
  23. <exclusions>
  24. <exclusion>
  25. <groupId>org.springframework.boot</groupId>
  26. <artifactId>spring-boot-starter-logging</artifactId>
  27. </exclusion>
  28. </exclusions>
  29. </dependency>
  30. <dependency>
  31. <groupId>org.springframework.boot</groupId>
  32. <artifactId>spring-boot-starter-log4j</artifactId>
  33. <version>1.3.8.RELEASE</version>
  34. </dependency>
  35. <dependency>
  36. <groupId>org.springframework.boot</groupId>
  37. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  38. </dependency>
  39.  
  40. <dependency>
  41. <groupId>org.mybatis.spring.boot</groupId>
  42. <artifactId>mybatis-spring-boot-starter</artifactId>
  43. <version>2.0.1</version>
  44. </dependency>
  45.  
  46. <!-- 数据库连接池 -->
  47. <dependency>
  48. <groupId>com.alibaba</groupId>
  49. <artifactId>druid</artifactId>
  50. <version>1.1.11</version>
  51. </dependency>
  52. <dependency>
  53. <groupId>mysql</groupId>
  54. <artifactId>mysql-connector-java</artifactId>
  55. </dependency>
  56.  
  57. </dependencies>
  58.  
  59. <build>
  60. <finalName>${project.artifactId}</finalName>
  61. <plugins>
  62. <plugin>
  63. <groupId>org.apache.maven.plugins</groupId>
  64. <artifactId>maven-compiler-plugin</artifactId>
  65. <configuration>
  66. <source>1.8</source>
  67. <target>1.8</target>
  68. <encoding>UTF-8</encoding>
  69. </configuration>
  70. </plugin>
  71.  
  72. <plugin>
  73. <groupId>org.springframework.boot</groupId>
  74. <artifactId>spring-boot-maven-plugin</artifactId>
  75. <executions>
  76. <execution>
  77. <goals>
  78. <goal>repackage</goal>
  79. </goals>
  80. </execution>
  81. </executions>
  82. </plugin>
  83. </plugins>
  84. </build>
  85. </project>

3.   启动类 Starter.java

  1. package com.java.springboot;
  2.  
  3. import org.springframework.boot.SpringApplication;
  4. import org.springframework.boot.autoconfigure.SpringBootApplication;
  5. import org.springframework.boot.builder.SpringApplicationBuilder;
  6. import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  7.  
  8. /**
  9. * 启动类
  10. *
  11. * @author Logan
  12. * @version 1.0.0
  13. *
  14. */
  15. @SpringBootApplication
  16. public class Starter extends SpringBootServletInitializer {
  17.  
  18. public static void main(String[] args) {
  19. SpringApplication.run(Starter.class, args);
  20. }
  21.  
  22. @Override
  23. protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
  24. return builder.sources(Starter.class);
  25. }
  26.  
  27. }

4.   User.java

  1. package com.java.springboot.pojo;
  2.  
  3. public class User {
  4. private String id;
  5.  
  6. private String username;
  7.  
  8. private String password;
  9.  
  10. private Integer age;
  11.  
  12. public String getId() {
  13. return id;
  14. }
  15.  
  16. public void setId(String id) {
  17. this.id = id;
  18. }
  19.  
  20. public String getUsername() {
  21. return username;
  22. }
  23.  
  24. public void setUsername(String username) {
  25. this.username = username;
  26. }
  27.  
  28. public String getPassword() {
  29. return password;
  30. }
  31.  
  32. public void setPassword(String password) {
  33. this.password = password;
  34. }
  35.  
  36. public Integer getAge() {
  37. return age;
  38. }
  39.  
  40. public void setAge(Integer age) {
  41. this.age = age;
  42. }
  43.  
  44. @Override
  45. public String toString() {
  46. return "User [id=" + id + ", username=" + username + ", password=" + password + ", age=" + age + "]";
  47. }
  48.  
  49. }

5.   UserMapper.java

  1. package com.java.springboot.mapper;
  2.  
  3. import java.util.List;
  4.  
  5. import com.java.springboot.pojo.User;
  6.  
  7. public interface UserMapper {
  8.  
  9. Integer checkLogin(User user);
  10.  
  11. List<User> findUserList(User user);
  12.  
  13. void addUser(User user);
  14.  
  15. void updateUser(User user);
  16.  
  17. void deleteUser(User user);
  18.  
  19. }

6.   UserMapper.xml

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5.  
  6. <mapper namespace="com.java.springboot.mapper.UserMapper">
  7.  
  8. <!-- 配置数据库字段和实体类映射 -->
  9. <resultMap id="userMap" type="com.java.springboot.pojo.User">
  10. <id property="id" column="id" />
  11. <result property="username" column="username" />
  12. <result property="password" column="password" />
  13. <result property="age" column="age" />
  14. </resultMap>
  15.  
  16. <!-- 检查登录 -->
  17. <select id="checkLogin" parameterType="com.java.springboot.pojo.User" resultType="java.lang.Integer">
  18. select 1 from user where username=#{username} and password=#{password}
  19. </select>
  20.  
  21. <!-- 查询用户列表 -->
  22. <select id="findUserList" parameterType="com.java.springboot.pojo.User" resultType="com.java.springboot.pojo.User">
  23. select id,username,password,age from user
  24. </select>
  25.  
  26. <!-- 新增用户 -->
  27. <insert id="addUser" parameterType="com.java.springboot.pojo.User" >
  28. <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String">
  29. select replace(uuid(), '-', '') as id from dual
  30. </selectKey>
  31. insert into user(id,username,password,age) values(#{id},#{username},#{password},#{age});
  32. </insert>
  33.  
  34. <!-- 修改用户信息 -->
  35. <update id="updateUser" parameterType="com.java.springboot.pojo.User" >
  36. update user set username=#{username}, password=#{password}, age=#{age} where id=#{id}
  37. </update>
  38.  
  39. <!-- 根据id删除用户 -->
  40. <delete id="deleteUser" parameterType="java.lang.String">
  41. delete from user where id=#{id}
  42. </delete>
  43.  
  44. </mapper>

7、UserService.java

  1. package com.java.springboot.service;
  2.  
  3. import java.util.List;
  4.  
  5. import com.java.springboot.pojo.User;
  6.  
  7. public interface UserService {
  8.  
  9. Integer checkLogin(User user);
  10.  
  11. List<User> findUserList(User user);
  12.  
  13. void addOrUpdateUser(User user);
  14.  
  15. void deleteUser(User user);
  16.  
  17. }

8、UserServiceImpl.java

  1. package com.java.springboot.service.impl;
  2.  
  3. import java.util.List;
  4.  
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. import org.springframework.transaction.annotation.Transactional;
  8.  
  9. import com.java.springboot.mapper.UserMapper;
  10. import com.java.springboot.pojo.User;
  11. import com.java.springboot.service.UserService;
  12.  
  13. @Service("userService")
  14. public class UserServiceImpl implements UserService {
  15.  
  16. @Autowired
  17. private UserMapper userMapper;
  18.  
  19. @Override
  20. public Integer checkLogin(User user) {
  21. return userMapper.checkLogin(user);
  22. }
  23.  
  24. @Override
  25. public List<User> findUserList(User user) {
  26. return userMapper.findUserList(user);
  27. }
  28.  
  29. @Override
  30. @Transactional
  31. public void addOrUpdateUser(User user) {
  32. if (null == user.getId() || user.getId().isEmpty()) {
  33. userMapper.addUser(user);
  34. } else {
  35. userMapper.updateUser(user);
  36. }
  37. }
  38.  
  39. @Override
  40. @Transactional
  41. public void deleteUser(User user) {
  42. userMapper.deleteUser(user);
  43. }
  44.  
  45. }

9、UserController.java

  1. package com.java.springboot.controller;
  2.  
  3. import java.util.List;
  4.  
  5. import org.apache.commons.logging.Log;
  6. import org.apache.commons.logging.LogFactory;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.ui.Model;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12.  
  13. import com.java.springboot.pojo.User;
  14. import com.java.springboot.service.UserService;
  15.  
  16. @Controller
  17. @RequestMapping("/user")
  18. public class UserController {
  19.  
  20. private static final Log LOG = LogFactory.getLog(UserController.class);
  21.  
  22. @Autowired
  23. private UserService userService;
  24.  
  25. @RequestMapping("/login")
  26. public String login() {
  27. return "user/login";
  28. }
  29.  
  30. @RequestMapping("/checkLogin")
  31. public String checkLogin(User user, Model model) {
  32. LOG.info("Into checkLogin");
  33. System.out.println(user);
  34.  
  35. String responseUrl = null;
  36.  
  37. // 检查用户名密码是否存在
  38. Integer result = userService.checkLogin(user);
  39. System.out.println("result: " + result);
  40. LOG.info("result: " + result);
  41.  
  42. // 绑定用户名密码输出返回
  43. if (null == result) {
  44. model.addAttribute("username", user.getUsername());
  45. model.addAttribute("password", user.getPassword());
  46. responseUrl = "user/login";
  47. }
  48.  
  49. // 登录成功,访问主页
  50. else {
  51. responseUrl = "user/main";
  52. }
  53.  
  54. LOG.info("Exit checkLogin");
  55. return responseUrl;
  56.  
  57. }
  58.  
  59. @ResponseBody
  60. @RequestMapping("/findUserList")
  61. public List<User> findUserList(User user) {
  62. LOG.info("Into findUserList");
  63. System.out.println(user);
  64.  
  65. List<User> list = userService.findUserList(user);
  66.  
  67. LOG.info("Exit findUserList");
  68. return list;
  69. }
  70.  
  71. @RequestMapping("/toAddOrUpdateUser")
  72. public String toAddOrUpdateUser(User user, Model model) {
  73. LOG.info("Into toAddOrUpdateUser");
  74. System.out.println("user: " + user);
  75.  
  76. // 输出id,根据id是否为空,判断是新增还是修改
  77. model.addAttribute("user", user);
  78. LOG.info("Exit toAddOrUpdateUser");
  79. return "user/addOrUpdateUser";
  80. }
  81.  
  82. @RequestMapping("/addOrUpdate")
  83. public String addOrUpdate(User user) {
  84. LOG.info("Into addOrUpdate");
  85. System.out.println("user: " + user);
  86.  
  87. userService.addOrUpdateUser(user);
  88.  
  89. System.out.println(user);
  90. LOG.info("Exit addOrUpdate");
  91.  
  92. return "user/main";
  93.  
  94. }
  95.  
  96. @ResponseBody
  97. @RequestMapping("/deleteUser")
  98. public String deleteUser(User user) {
  99. System.out.println(user);
  100. LOG.info("Into deleteUser");
  101.  
  102. userService.deleteUser(user);
  103.  
  104. LOG.info("Exit deleteUser");
  105. return "删除成功!";
  106. }
  107.  
  108. }

10、ApplicationConfig.java

  1. package com.java.springboot.config;
  2.  
  3. import org.mybatis.spring.annotation.MapperScan;
  4. import org.springframework.context.annotation.Configuration;
  5.  
  6. /**
  7. * 配置类
  8. *
  9. * @author Logan
  10. * @version 1.0.0
  11. *
  12. */
  13. @Configuration
  14. @MapperScan({ "com.java.springboot.mapper" })
  15. public class ApplicationConfig {
  16.  
  17. }

11、src/main/resources 下配置文件

12、application.properties

  1. server.port=8080
  2.  
  3. #数据库自动配置
  4. spring.datasource.driver-class-name=com.mysql.jdbc.Driver
  5. spring.datasource.url=jdbc:mysql://192.168.32.10:3306/springboot?useUnicode=true&characterEncoding=UTF-8
  6. spring.datasource.username=root
  7. spring.datasource.password=123456
  8. spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
  9.  
  10. #Thymeleaf 参见org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties
  11. spring.thymeleaf.prefix=classpath:/views/
  12. spring.thymeleaf.suffix=.html

13、log4j.properties

  1. log4j.rootLogger= INFO, stdout,logfile
  2. log4j.logger.INFO=INFO,logfile
  3.  
  4. log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  5. log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  6. log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss.SSS} [%5p] [%c] - %m%n
  7.  
  8. log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
  9. log4j.appender.logfile.File=G:/Java/logs/springboot/LogFile.log
  10. log4j.appender.logfile.DatePattern='_'yyyy-MM-dd'.log'
  11. log4j.appender.logfile.Threshold=INFO
  12. log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
  13. log4j.appender.logfile.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} [%5p] - %m%n
  14. log4j.appender.logfile.Append=true

14、/static/index.html

  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.  
  6. <title>登录</title>
  7. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  8. <script type="text/javascript">
  9. function addUser() {
  10. location.href = "/user/toAddOrUpdateUser";
  11. }
  12. </script>
  13. </head>
  14.  
  15. <body>
  16. <form action="/user/checkLogin" method="post">
  17. <table>
  18. <tr>
  19. <td>用户名:</td>
  20. <td><input name="username" /><br /></td>
  21. </tr>
  22. <tr>
  23. <td>密码:</td>
  24. <td><input type="password" name="password" /><br /></td>
  25. </tr>
  26. <tr>
  27. <td><input type="submit" value="登录" /></td>
  28. <td><input type="button" value="注册" onclick="addUser();" /></td>
  29. </tr>
  30. </table>
  31.  
  32. </form>
  33.  
  34. </body>
  35.  
  36. </html>

15、/views/user/login.html

  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3.  
  4. <head>
  5.  
  6. <title>登录</title>
  7. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  8. <script type="text/javascript">
  9. function addUser() {
  10. location.href = "/user/toAddOrUpdateUser";
  11. }
  12. </script>
  13. </head>
  14.  
  15. <body>
  16. <form action="/user/checkLogin" method="post">
  17. <table>
  18. <tr>
  19. <td>用户名:</td>
  20. <td><input name="username" th:value="${username}" /><br /></td>
  21. </tr>
  22. <tr>
  23. <td>密码:</td>
  24. <td><input type="password" name="password" th:value="${password}" /><br /></td>
  25. </tr>
  26. <tr>
  27. <td><input type="submit" value="登录" /></td>
  28. <td><input type="button" value="注册" onclick="addUser();" /></td>
  29. </tr>
  30. </table>
  31.  
  32. </form>
  33.  
  34. </body>
  35.  
  36. </html>

16、/views/user/main.html

  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.  
  6. <title>主页</title>
  7. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  8. <script src="/js/jquery-3.3.1.min.js"></script>
  9. <style type="text/css">
  10. td,
  11. th {
  12. border: 1px solid #AAA;
  13. }
  14. </style>
  15. <script type="text/jscript">
  16. $(function() {
  17. queryUserList();
  18. });
  19.  
  20. function queryUserList() {
  21. $.post("/user/findUserList", {
  22. id: 1
  23. }, function(data) {
  24. var userList = data;
  25. var line = null;
  26. $("#list").empty();
  27. for(var i in userList) {
  28. line = tr(td(userList[i].id) + td(userList[i].username) + td(userList[i].password) + td(userList[i].age) + td(addBtn() + delBtn()));
  29. $("#list").append(line);
  30. }
  31. });
  32. }
  33.  
  34. function tr(text) {
  35. return "<tr>" + text + "</tr>";
  36. }
  37.  
  38. function td(text) {
  39. if(!text) {
  40. text = "";
  41. }
  42. return "<td>" + text + "</td>";
  43. }
  44.  
  45. function addBtn() {
  46. return "<button onClick='update(this);'>修改</button>";
  47. }
  48.  
  49. function delBtn() {
  50. return "<button onClick='deleteUser(this);'>删除</button>";
  51. }
  52.  
  53. function update(obj) {
  54. var row = getRow(obj);
  55.  
  56. var user = {
  57. id: row.eq(0).text(),
  58. username: row.eq(1).text(),
  59. password: row.eq(2).text(),
  60. age: row.eq(3).text()
  61. }
  62.  
  63. var form = document.createElement("form");
  64. form.action = "/user/toAddOrUpdateUser";
  65. form.method = "post";
  66.  
  67. var input = null;
  68. for(var key in user) {
  69. input = document.createElement("input");
  70.  
  71. input.type = "hidden";
  72. input.name = key;
  73. input.value = user[key];
  74. form.appendChild(input)
  75. }
  76. document.body.appendChild(form);
  77. form.submit();
  78.  
  79. }
  80.  
  81. function deleteUser(obj) {
  82. var row = getRow(obj);
  83.  
  84. var id = row.eq(0).text();
  85. $.post("/user/deleteUser", {
  86. id: id
  87. }, function(data) {
  88. alert(data);
  89. queryUserList();
  90. });
  91. }
  92.  
  93. function getRow(obj) {
  94. return $(obj).parent().parent().children();
  95. }
  96. </script>
  97. </head>
  98.  
  99. <body>
  100. <button onClick="location.href='/user/toAddOrUpdateUser'">新增</button>
  101. <div>
  102. <table style="border-collapse: collapse; width: 800px;">
  103. <thead>
  104. <tr>
  105. <th>ID</th>
  106. <th>用户名</th>
  107. <th>密码</th>
  108. <th>年龄</th>
  109. <th>操作</th>
  110. </tr>
  111. </thead>
  112. <tbody id="list">
  113. </tbody>
  114. </table>
  115. </div>
  116.  
  117. </body>
  118.  
  119. </html>

17、/views/user/addOrUpdateUser.html

  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org">
  3.  
  4. <head>
  5.  
  6. <title>新增用户</title>
  7. <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  8. </head>
  9.  
  10. <body>
  11. <form action="/user/addOrUpdate" method="post">
  12. <input name="id" th:value="${user.id}" type="hidden" />
  13. <table>
  14. <tr>
  15. <td>用户名:</td>
  16. <td><input type="text" name="username" th:value="${user.username}" /><br /></td>
  17. </tr>
  18. <tr>
  19. <td>密码:</td>
  20. <td><input type="password" name="password" th:value="${user.password}" /><br /></td>
  21. </tr>
  22. <tr>
  23. <td>年龄:</td>
  24. <td><input type="text" name="age" th:value="${user.age}" /><br /></td>
  25. </tr>
  26. <tr>
  27. <td colspan="2"><input type="submit" value="提交" /></td>
  28. </tr>
  29. </table>
  30.  
  31. </form>
  32.  
  33. </body>
  34.  
  35. </html>

18.    创建数据库

  1. DROP DATABASE IF EXISTS springboot;
  2. CREATE DATABASE springboot;
  3. USE springboot;
  4. DROP TABLE IF EXISTS `user`;
  5. CREATE TABLE `user` (
  6. `id` varchar(32) NOT NULL,
  7. `username` varchar(32) NOT NULL,
  8. `password` varchar(32) NOT NULL,
  9. `age` int(3) DEFAULT NULL,
  10. PRIMARY KEY (`id`)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  12.  
  13. ;

注意:

jquery-3.3.1.min.js 请自行下载,配置到Main.jsp文件中

https://code.jquery.com/jquery-3.3.1.min.js
    http://code.jquery.com/jquery-3.3.1.min.js

打开网址,Ctrl + S 保存文件

配置完成!

运行   Starter.java   ,在浏览器输入下面地址访问

http://127.0.0.1:8080

.

springboot框架快速搭建的更多相关文章

  1. springBoot框架的搭建

    1新建一个项目: 2.注意选择JDK1.8,和选择spring initializr加载springBoot相关jar包: 3.下一步next: 4.下一步next,选择Web和MyBatis然后ne ...

  2. 玩转 SpringBoot 2 快速搭建 | RESTful Api 篇

    概述 RESTful 是一种架构风格,任何符合 RESTful 风格的架构,我们都可以称之为 RESTful 架构.我们常说的 RESTful Api 是符合 RESTful 原则和约束的 HTTP ...

  3. ASP.NET MVC项目框架快速搭建实战

    MVC项目搭建笔记---- 项目框架采用ASP.NET MVC+Entity Framwork+Spring.Net等技术搭建,采用”Domain Model as View Model“的MVC开发 ...

  4. springboot项目快速搭建

    1. 问题描述 springboot的面世,成为Java开发者的一大福音,大大提升了开发的效率,其实springboot只是在maven的基础上,对已有的maven gav进行了封装而已,今天用最简单 ...

  5. 玩转SpringBoot 2 快速搭建 | Spring Initializr 篇

    SpringBoot 为我们提供了外网 Spring Initializr 网页版来帮助我们快速搭建 SpringBoot 项目,如果你不想用 IDEA 中的插件,这种方式也是不错的选择.闲话少说,直 ...

  6. 玩转 SpringBoot 2 快速搭建 | Spring Tool Suite篇

    Spring Tool Suite (STS) 工具介绍 我个人比较推荐使用 Spring Tool Suite(STS),之所以推荐使用 Spring Tool Suite(STS) ,是因为它是 ...

  7. Django+Vue.js框架快速搭建web项目

    一.vue环境搭建1.下载安装node.js.2.安装淘宝镜像cnpm,在命令窗口输入: npm install -g cnpm --registry=https://registry.npm.tao ...

  8. SpringBoot 1.快速搭建一个 SpringBoot Maven工程

    一.新建一个Maven工程 (1)选择创建简单MAVNE工程 (2)输入你自己的MAVEN工程的Group Id(必填).Artifact Id(必填).Version(必填).Packaging(必 ...

  9. 玩转 SpringBoot 2 快速搭建 | IntellJ IDEA篇

     IntellJ IDEA 介绍  IntelliJ IDEA 简称 IDEA,目前被认为是最好用的开发Java 语言开发工具之一.不过是收费的.和其同类型的工具有 Eclipse 和 MyEclip ...

随机推荐

  1. Linux调优(内存,CPU)

    一.相关概念简介 system call:系统调用 time slice:cpu时间片 O(1):Linux系统进程调度器 page frame:分页 RSS:常驻内存集,无法被页面化的数据 MMU: ...

  2. 关于dijkstra求最短路(模板)

    嗯....   dijkstra是求最短路的一种算法(废话,思维含量较低,   并且时间复杂度较为稳定,为O(n^2),   但是注意:!!!!         不能处理边权为负的情况(但SPFA可以 ...

  3. Codeforces Round #364 (Div. 2) A

    Description There are n cards (n is even) in the deck. Each card has a positive integer written on i ...

  4. 自动化测试资源(一):谷歌浏览器驱动 ChromeDriver

    ChromeDriver(官网):https://sites.google.com/a/chromium.org/chromedriver/ (需要XX上网,官网里有驱动和浏览器的版本映射关系) (如 ...

  5. Hadoop源生实用工具之distcp

    1 概览 DistCp(Distributed Copy)是用于大规模集群内部或者集群之间的高性能拷贝工具. 它使用Map/Reduce实现文件分发,错误处理和恢复,以及报告生成. 它把文件和目录的列 ...

  6. C#中动态创建数据库和数据表,很经典【转】

    用ADOX创建access数据库方法很简单,只需要new一个Catalog对象,然后调用它的Create方法就可以了,如下: ADOX.Catalog catalog = new Catalog(); ...

  7. javascript获取滚动条位置(兼容所有浏览器)

    有两种方式来获取浏览器滚动条的位置 第一种:document.documentElement.scrollTop 第二种:$("body").scrollTop() 第一种方式能够 ...

  8. C#获得字符串首字符字母(大写)

    /// <summary> /// 获得字符串首字符字母(大写): /// </summary> /// <param name="cnChar"&g ...

  9. CF1152C Neko does Maths

    思路: 假设a <= b,lcm(a + k, b + k) = (a + k) * (b + k) / gcd(a + k, b + k) = (a + k) * (b + k) / gcd( ...

  10. 深入剖析javaScript中的深拷贝和浅拷贝

    如何区分深拷贝与浅拷贝,简单来说,假设B复制了A,当修改A时,看B是否会发生变化,如果B也跟着变了,说明这是浅拷贝,如果B没变,那就是深拷贝:我们先看两个简单的案例: //案例1(深拷贝) var a ...