Commit 44c0de47edbf25e308499abdfa52a33d1361349d

Authored by 陶汉栋
1 parent 9e0d66b1
Exists in master

no message

springboot/pom.xml
... ... @@ -26,6 +26,11 @@
26 26  
27 27 <dependency>
28 28 <groupId>org.springframework.boot</groupId>
  29 + <artifactId>spring-boot-starter-jdbc</artifactId>
  30 + </dependency>
  31 +
  32 + <dependency>
  33 + <groupId>org.springframework.boot</groupId>
29 34 <artifactId>spring-boot-starter-test</artifactId>
30 35 <scope>test</scope>
31 36 </dependency>
... ... @@ -46,8 +51,7 @@
46 51 <dependency>
47 52 <groupId>com.microsoft.sqlserver</groupId>
48 53 <artifactId>mssql-jdbc</artifactId>
49   - <version>7.2.1.jre8</version>
50   - <scope>test</scope>
  54 + <scope>runtime</scope>
51 55 </dependency>
52 56  
53 57 <dependency>
... ...
springboot/src/main/java/com/sincre/springboot/SpringbootApplication.java
... ... @@ -10,24 +10,24 @@ import java.awt.*;
10 10  
11 11 @MapperScan("com.sincre.springboot.mapper")
12 12 @SpringBootApplication
13   -public class SpringbootApplication{
  13 +public class SpringbootApplication {
14 14  
15 15 public static void main(String[] args) {
16 16  
17 17 SpringApplication.run(SpringbootApplication.class, args);
18   - System.out.println("classpath:"+new SpringbootApplication().getClass().getResource(""));
  18 + System.out.println("classpath:" + new SpringbootApplication().getClass().getResource(""));
19 19  
20 20 // new SpringbootApplication().initFrame();
21 21 }
22 22  
23   - private void initFrame(){
  23 + private void initFrame() {
24 24 JFrame jFrame = new JFrame();
25 25 //设置窗口是否可视
26 26 jFrame.setVisible(true);
27 27 //设置窗口的大小是否可以调节
28 28 jFrame.setResizable(false);
29 29 //设置窗口大小和x,y位置
30   - jFrame.setBounds(100,100, 600, 800);
  30 + jFrame.setBounds(100, 100, 600, 800);
31 31 //设置窗口退出则程序退出
32 32 jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
33 33 }
... ...
springboot/src/main/java/com/sincre/springboot/Swagger2.java
... ... @@ -15,7 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
15 15 public class Swagger2 {
16 16  
17 17 @Bean
18   - public Docket createRestApi(){
  18 + public Docket createRestApi() {
19 19 return new Docket(DocumentationType.SWAGGER_2)
20 20 .apiInfo(apiInfo())
21 21 .select()
... ... @@ -24,7 +24,7 @@ public class Swagger2 {
24 24 .build();
25 25 }
26 26  
27   - private ApiInfo apiInfo(){
  27 + private ApiInfo apiInfo() {
28 28 return new ApiInfoBuilder()
29 29 .title("Spring Boot中使用Swagger2")
30 30 .contact("Mr.Tao")
... ...
springboot/src/main/java/com/sincre/springboot/controller/UserController.java
... ... @@ -50,8 +50,8 @@ public class UserController {
50 50 return "登录成功";
51 51 }
52 52  
53   - @RequestMapping(method = RequestMethod.GET,value = "getImg")
54   - public String getImg(){
  53 + @RequestMapping(method = RequestMethod.GET, value = "getImg")
  54 + public String getImg() {
55 55 return FileUtils.getImageStr("C:\\Users\\taohandong\\Desktop\\微耕.png");
56 56 }
57 57  
... ...
springboot/src/main/java/com/sincre/springboot/mapper/UserMapper.java
... ... @@ -9,9 +9,9 @@ import org.springframework.stereotype.Repository;
9 9 @Repository
10 10 public interface UserMapper {
11 11  
12   - public User login(@Param("userName") String userName,@Param("password") String password);
  12 + public User login(@Param("userName") String userName, @Param("password") String password);
13 13  
14   - public boolean register(@Param("username") String username,@Param("password") String password);
  14 + public boolean register(@Param("username") String username, @Param("password") String password);
15 15  
16   - public User isExit(@Param("username")String username);
  16 + public User isExit(@Param("username") String username);
17 17 }
... ...
springboot/src/main/java/com/sincre/springboot/server/UserServer.java
... ... @@ -7,9 +7,9 @@ public interface UserServer {
7 7  
8 8 public boolean insertUser(User user);
9 9  
10   - public User login(String loginname,String password);
  10 + public User login(String loginname, String password);
11 11  
12   - public boolean registr(String username,String password);
  12 + public boolean registr(String username, String password);
13 13  
14 14 public User isExit(String username);
15 15 }
... ...
springboot/src/main/java/com/sincre/springboot/server/UserServerImp.java
... ... @@ -19,12 +19,12 @@ public class UserServerImp implements UserServer {
19 19  
20 20 @Override
21 21 public User login(String loginname, String password) {
22   - return userMapper.login(loginname,password);
  22 + return userMapper.login(loginname, password);
23 23 }
24 24  
25 25 @Override
26 26 public boolean registr(String username, String password) {
27   - return userMapper.register(username,password);
  27 + return userMapper.register(username, password);
28 28 }
29 29  
30 30 @Override
... ...
springboot/src/main/java/com/sincre/springboot/utils/FileUtils.java
... ... @@ -41,10 +41,10 @@ public class FileUtils {
41 41 }
42 42  
43 43 /**
  44 + * @return
44 45 * @Description: 根据图片地址转换为base64编码字符串
45 46 * @Author:
46 47 * @CreateTime:
47   - * @return
48 48 */
49 49 public static String getImageStr(String imgFile) {
50 50 InputStream inputStream = null;
... ...
springboot/src/main/resources/application.properties
1 1 server.port=1111
2   -
3 2 # ÉèÖÃÊý¾Ý¿âÏà¹ØÊôÐÔ
4 3 spring.datasource.username=thd
5 4 spring.datasource.password=pmd19930415A
6 5 spring.datasource.url=jdbc:sqlserver://60.190.202.57:14333;database=test
7 6 spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
8   -
9 7 mybatis.config-location=classpath:mybatis-config.xml
10 8 mybatis.mapper-locations=classpath:/mapper/*.xml
11 9 mybatis.type-aliases-package=com.sincre.springboot.model
12 10 \ No newline at end of file
... ...
springboot/src/main/resources/mapper/usermapper.xml
... ... @@ -8,13 +8,13 @@
8 8 select *
9 9 from "User"
10 10 where username = #{userName}
11   - and password = #{password}
  11 + and password = #{password}
12 12 </select>
13 13  
14 14 <insert id="register" parameterType="com.sincre.springboot.model.User"
15 15 useGeneratedKeys="true">
16 16 <!--<selectKey keyProperty="id" resultType="int" order="BEFORE">-->
17   --- SELECT LAST_INSERT_ID() AS ID
  17 + -- SELECT LAST_INSERT_ID() AS ID
18 18 <!--</selectKey>-->
19 19 insert into "User"(username, password) VALUES (#{username},#{password})
20 20 </insert>
... ...