Skip to content

Commit 1b0de99

Browse files
committed
Java:APIJSONDemo-RawSQL 升级 JDK 17,APIJSON 7.1.0, apijson-framework …
1 parent febfac8 commit 1b0de99

File tree

7 files changed

+28
-25
lines changed

7 files changed

+28
-25
lines changed

APIJSON-Java-Server/APIJSONDemo-RawSQL/pom.xml

+10-7
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,36 @@
55
<groupId>apijson.demo</groupId>
66
<artifactId>apijson-demo-druid-rawSQL</artifactId>
77
<packaging>jar</packaging>
8-
<version>7.0.3</version>
8+
<version>7.1.5</version>
99

1010
<name>APIJSONDemo-Druid</name>
1111
<description>Demo project for Testing APIJSON Server based on SpringBoot</description>
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
16-
<java.version>1.8</java.version>
16+
<java.version>17</java.version>
17+
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
18+
<maven.compiler.source>17</maven.compiler.source>
19+
<maven.compiler.target>17</maven.compiler.target>
1720
</properties>
1821

1922
<dependencies>
2023
<!-- 需要的 APIJSON 相关依赖 -->
2124
<dependency>
2225
<groupId>com.github.Tencent</groupId>
2326
<artifactId>APIJSON</artifactId>
24-
<version>7.0.3</version>
27+
<version>7.1.0</version>
2528
</dependency>
2629
<dependency>
2730
<groupId>com.github.APIJSON</groupId>
2831
<artifactId>apijson-framework</artifactId>
29-
<version>7.0.3</version>
32+
<version>7.1.5</version>
3033
</dependency>
3134
<dependency>
3235
<groupId>com.github.APIJSON</groupId>
3336
<artifactId>apijson-router</artifactId>
34-
<version>2.0.3</version>
37+
<version>2.1.5</version>
3538
</dependency>
3639

3740
<!-- 需要用的数据库 JDBC 驱动 -->
@@ -82,8 +85,8 @@
8285
<artifactId>maven-compiler-plugin</artifactId>
8386
<version>3.8.1</version>
8487
<configuration>
85-
<source>1.8</source>
86-
<target>1.8</target>
88+
<source>17</source>
89+
<target>17</target>
8790
</configuration>
8891
</plugin>
8992
</plugins>

APIJSON-Java-Server/APIJSONDemo-RawSQL/src/main/java/apijson/demo/DemoApplication.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
2929

3030
import apijson.Log;
31-
import apijson.framework.APIJSONApplication;
32-
import apijson.framework.APIJSONCreator;
31+
import apijson.framework.javax.APIJSONApplication;
32+
import apijson.framework.javax.APIJSONCreator;
3333
import apijson.orm.FunctionParser;
3434
import apijson.orm.SQLConfig;
3535
import apijson.orm.SQLExecutor;
@@ -87,19 +87,19 @@ public void addCorsMappings(CorsRegistry registry) {
8787

8888
static {
8989
// 使用本项目的自定义处理类
90-
APIJSONApplication.DEFAULT_APIJSON_CREATOR = new APIJSONCreator<Long>() {
90+
APIJSONApplication.DEFAULT_APIJSON_CREATOR = new APIJSONCreator<String>() {
9191
@Override
92-
public SQLConfig createSQLConfig() {
92+
public SQLConfig<String> createSQLConfig() {
9393
return new DemoSQLConfig();
9494
}
9595

9696
@Override
97-
public SQLExecutor createSQLExecutor() {
97+
public SQLExecutor<String> createSQLExecutor() {
9898
return new DemoSQLExecutor();
9999
}
100100

101101
@Override
102-
public FunctionParser createFunctionParser() {
102+
public FunctionParser<String> createFunctionParser() {
103103
return new DemoFunctionParser();
104104
}
105105
};

APIJSON-Java-Server/APIJSONDemo-RawSQL/src/main/java/apijson/demo/DemoController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import apijson.RequestMethod;
3131
import apijson.StringUtil;
3232
import apijson.orm.Parser;
33-
import apijson.router.APIJSONRouterController;
33+
import apijson.router.javax.APIJSONRouterController;
3434

3535

3636
/**请求路由入口控制器,包括通用增删改查接口等,转交给 APIJSON 的 Parser 来处理

APIJSON-Java-Server/APIJSONDemo-RawSQL/src/main/java/apijson/demo/DemoFunctionParser.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
import apijson.NotNull;
1717
import apijson.RequestMethod;
1818
import apijson.StringUtil;
19-
import apijson.framework.APIJSONConstant;
20-
import apijson.framework.APIJSONFunctionParser;
21-
import apijson.router.APIJSONRouterVerifier;
19+
import apijson.framework.javax.APIJSONConstant;
20+
import apijson.framework.javax.APIJSONFunctionParser;
21+
import apijson.router.javax.APIJSONRouterVerifier;
2222

23-
public class DemoFunctionParser extends APIJSONFunctionParser {
23+
public class DemoFunctionParser extends APIJSONFunctionParser<String> {
2424
public DemoFunctionParser() {
2525
this(null, null, 0, null, null);
2626
}

APIJSON-Java-Server/APIJSONDemo-RawSQL/src/main/java/apijson/demo/DemoSQLConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
package apijson.demo;
1616

17-
import apijson.framework.APIJSONSQLConfig;
17+
import apijson.framework.javax.APIJSONSQLConfig;
1818

1919

2020
/**SQL 配置,这里不配置数据库账号密码等信息,改为使用 DemoDataSourceConfig 来配置
@@ -23,7 +23,7 @@
2323
* https://github.com/Tencent/APIJSON/blob/master/%E8%AF%A6%E7%BB%86%E7%9A%84%E8%AF%B4%E6%98%8E%E6%96%87%E6%A1%A3.md#c-1-1%E4%BF%AE%E6%94%B9%E6%95%B0%E6%8D%AE%E5%BA%93%E9%93%BE%E6%8E%A5
2424
* @author Lemon
2525
*/
26-
public class DemoSQLConfig extends APIJSONSQLConfig<Long> {
26+
public class DemoSQLConfig extends APIJSONSQLConfig<String> {
2727

2828
static {
2929
DEFAULT_DATABASE = DATABASE_MYSQL; // TODO 默认数据库类型,改成你自己的

APIJSON-Java-Server/APIJSONDemo-RawSQL/src/main/java/apijson/demo/DemoSQLExecutor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@
1818

1919
import javax.sql.DataSource;
2020

21-
import apijson.framework.APIJSONSQLExecutor;
21+
import apijson.framework.javax.APIJSONSQLExecutor;
2222
import apijson.orm.SQLConfig;
2323

2424

2525
/**SQL 执行器,支持连接池及多数据源
2626
* 具体见 https://github.com/Tencent/APIJSON/issues/151
2727
* @author Lemon
2828
*/
29-
public class DemoSQLExecutor extends APIJSONSQLExecutor<Long> {
29+
public class DemoSQLExecutor extends APIJSONSQLExecutor<String> {
3030
public static final String TAG = "DemoSQLExecutor";
3131

3232
// 适配连接池,如果这里能拿到连接池的有效 Connection,则 SQLConfig 不需要配置 dbVersion, dbUri, dbAccount, dbPassword
3333
@Override
34-
public Connection getConnection(SQLConfig config) throws Exception {
34+
public Connection getConnection(SQLConfig<String> config) throws Exception {
3535
// Log.d(TAG, "getConnection config.getDatasource() = " + config.getDatasource());
3636

3737
String key = config.getDatasource() + "-" + config.getDatabase();

APIJSON-Java-Server/APIJSONDemo-RawSQL/src/main/resources/application.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ spring:
77
# password: apijson
88
druid:
99
driverClassName: com.mysql.cj.jdbc.Driver
10-
url: jdbc:mysql://localhost:3306/apijson?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8
10+
url: jdbc:mysql://localhost:3306?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8
1111
username: root
12-
password: root
12+
password: apijson
1313
type: com.alibaba.druid.pool.DruidDataSource
1414
initialSize: 5
1515
minIdle: 5

0 commit comments

Comments
 (0)