Skip to content

Commit 23e3247

Browse files
committed
升级版本及更新文档
1 parent 2eb5817 commit 23e3247

12 files changed

Lines changed: 320 additions & 255 deletions

File tree

Spring-Boot-MyBatis/.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,32 @@
11
/*
2-
Licensed to the Apache Software Foundation (ASF) under one
3-
or more contributor license agreements. See the NOTICE file
4-
distributed with this work for additional information
5-
regarding copyright ownership. The ASF licenses this file
6-
to you under the Apache License, Version 2.0 (the
7-
"License"); you may not use this file except in compliance
8-
with the License. You may obtain a copy of the License at
2+
* Copyright 2007-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
916

10-
https://www.apache.org/licenses/LICENSE-2.0
11-
12-
Unless required by applicable law or agreed to in writing,
13-
software distributed under the License is distributed on an
14-
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15-
KIND, either express or implied. See the License for the
16-
specific language governing permissions and limitations
17-
under the License.
18-
*/
19-
20-
import java.io.File;
21-
import java.io.FileInputStream;
22-
import java.io.FileOutputStream;
23-
import java.io.IOException;
24-
import java.net.URL;
25-
import java.nio.channels.Channels;
26-
import java.nio.channels.ReadableByteChannel;
17+
import java.net.*;
18+
import java.io.*;
19+
import java.nio.channels.*;
2720
import java.util.Properties;
2821

2922
public class MavenWrapperDownloader {
3023

24+
private static final String WRAPPER_VERSION = "0.5.6";
3125
/**
3226
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
3327
*/
34-
private static final String DEFAULT_DOWNLOAD_URL =
35-
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
28+
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
29+
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
3630

3731
/**
3832
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
@@ -80,13 +74,13 @@ public static void main(String args[]) {
8074
}
8175
}
8276
}
83-
System.out.println("- Downloading from: : " + url);
77+
System.out.println("- Downloading from: " + url);
8478

8579
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
8680
if (!outputFile.getParentFile().exists()) {
8781
if (!outputFile.getParentFile().mkdirs()) {
8882
System.out.println(
89-
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
83+
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
9084
}
9185
}
9286
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
@@ -102,6 +96,16 @@ public static void main(String args[]) {
10296
}
10397

10498
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
99+
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
100+
String username = System.getenv("MVNW_USERNAME");
101+
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
102+
Authenticator.setDefault(new Authenticator() {
103+
@Override
104+
protected PasswordAuthentication getPasswordAuthentication() {
105+
return new PasswordAuthentication(username, password);
106+
}
107+
});
108+
}
105109
URL website = new URL(urlString);
106110
ReadableByteChannel rbc;
107111
rbc = Channels.newChannel(website.openStream());
2.32 KB
Binary file not shown.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

Spring-Boot-MyBatis/mvnw

Lines changed: 29 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Spring-Boot-MyBatis/mvnw.cmd

Lines changed: 32 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Spring-Boot-MyBatis/pom.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>2.1.3.RELEASE</version>
8+
<version>2.2.5.RELEASE</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.example</groupId>
1212
<artifactId>mybatis</artifactId>
1313
<version>0.0.1-SNAPSHOT</version>
14-
<name>Spring-Boot-MyBatis</name>
14+
<name>Spring-Boot-Mybatis</name>
1515
<description>Demo project for Spring Boot</description>
1616

1717
<properties>
@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>org.mybatis.spring.boot</groupId>
3030
<artifactId>mybatis-spring-boot-starter</artifactId>
31-
<version>1.3.2</version>
31+
<version>2.1.1</version>
3232
</dependency>
3333
<!--mysql数据库驱动依赖-->
3434
<dependency>
@@ -39,13 +39,18 @@
3939
<dependency>
4040
<groupId>com.alibaba</groupId>
4141
<artifactId>druid-spring-boot-starter</artifactId>
42-
<version>1.1.10</version>
42+
<version>1.1.21</version>
4343
</dependency>
44-
4544
<dependency>
4645
<groupId>org.springframework.boot</groupId>
4746
<artifactId>spring-boot-starter-test</artifactId>
4847
<scope>test</scope>
48+
<exclusions>
49+
<exclusion>
50+
<groupId>org.junit.vintage</groupId>
51+
<artifactId>junit-vintage-engine</artifactId>
52+
</exclusion>
53+
</exclusions>
4954
</dependency>
5055
</dependencies>
5156

Spring-Boot-MyBatis/src/main/java/com/example/mybatis/SpringBootMyBatisApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55

66
@SpringBootApplication
7-
public class SpringBootMyBatisApplication {
7+
public class SpringBootMybatisApplication {
88

99
public static void main(String[] args) {
10-
SpringApplication.run(SpringBootMyBatisApplication.class, args);
10+
SpringApplication.run(SpringBootMybatisApplication.class, args);
1111
}
1212

1313
}

Spring-Boot-MyBatis/src/main/java/com/example/mybatis/controller/TestController.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
import com.example.mybatis.bean.Student;
44
import com.example.mybatis.service.StudentService;
5-
import org.springframework.beans.factory.annotation.Autowired;
6-
import org.springframework.web.bind.annotation.RequestMapping;
7-
import org.springframework.web.bind.annotation.RequestMethod;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.PathVariable;
87
import org.springframework.web.bind.annotation.RestController;
98

9+
import javax.annotation.Resource;
10+
1011
/**
1112
* Created by dengzhiming on 2019/3/21
1213
*/
1314
@RestController
1415
public class TestController {
15-
@Autowired
16+
@Resource
1617
private StudentService service;
1718

18-
@RequestMapping(value = "/querystudent", method = RequestMethod.GET)
19-
public Student queryStudentBySno(String sno) {
19+
@GetMapping("/querystudent/{sno}")
20+
public Student queryStudentBySno(@PathVariable String sno) {
2021
return this.service.queryStudentById(sno);
2122
}
2223

Spring-Boot-MyBatis/src/main/resources/application.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

Spring-Boot-MyBatis/src/main/resources/application.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@ mybatis:
6666
# type-aliases扫描路径
6767
# type-aliases-package:
6868
# com xml实现扫描路径
69-
mapper-locations: classpath:/mapper/*.xml
69+
mapper-locations: classpath:/mapper/*.xml
70+
configuration:
71+
# SQL日志输出
72+
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

0 commit comments

Comments
 (0)