zyl 8 months ago
parent
commit
ba27c7c159

+ 20 - 0
pom.xml

@@ -55,6 +55,26 @@
             <version>4.12</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.microsoft.sqlserver</groupId>
+            <artifactId>sqljdbc4</artifactId>
+            <version>4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.1.4</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.12</version>
+            <scope>provided</scope>
+        </dependency>
+
+
     </dependencies>
 
     <build>

+ 30 - 0
src/main/java/com/citygis/controller/testController.java

@@ -0,0 +1,30 @@
+package com.citygis.controller;
+
+import com.citygis.service.BigDataService;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.sql.SQLException;
+
+/**
+ * @Package com.citygis.controller
+ * @Author zyl
+ * @Date 2024/3/8 0008 20:43
+ * @description: 测试
+ */
+@RestController
+@CrossOrigin
+public class testController {
+
+    @Resource
+    BigDataService bigDataService;
+
+
+    @RequestMapping("/test")
+    public void testSqlServer() throws SQLException, ClassNotFoundException {
+        bigDataService.testSqlserver();
+    }
+
+}

+ 20 - 0
src/main/java/com/citygis/mapper/SqlServiceMapper.java

@@ -0,0 +1,20 @@
+package com.citygis.mapper;
+
+import com.citygis.pojo.SqlService;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * @Package com.citygis.mapper
+ * @Author zyl
+ * @Date 2024/3/8 0008 20:33
+ * @description: sqlserverceshi
+ */
+@Mapper
+public interface SqlServiceMapper {
+
+    List<SqlService> getAll();
+
+
+}

+ 19 - 0
src/main/java/com/citygis/pojo/SqlService.java

@@ -0,0 +1,19 @@
+package com.citygis.pojo;
+
+import lombok.Data;
+
+/**
+ * @Package com.citygis.pojo
+ * @Author zyl
+ * @Date 2024/3/8 0008 20:33
+ * @description: sqlserver实体类
+ */
+@Data
+public class SqlService {
+
+    private String id;
+
+    private String name;
+
+
+}

+ 20 - 0
src/main/resources/application.yml

@@ -0,0 +1,20 @@
+spring:
+  datasource:
+    url: jdbc:sqlserver://localhost:1433;DatabaseName=ke
+    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
+    username: zyl
+    password: 123456
+  servlet:
+    multipart:
+      max-file-size: 1024MB
+      max-request-size: 1024MB
+mybatis:
+  config-locations: classpath:mybatis/mybatis-config.xml
+  # 配置mapper的扫描,找到所有的mapper.xml映射文件
+  mapper-locations: classpath*:/mapper/*.xml,classpath*:/mapper/**/*.xml
+  # 搜索指定包别名
+  type-aliases-package: com.citygis.cdc.**.pojo
+#  configuration:
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+server:
+  port: 9006

+ 10 - 0
src/main/resources/mapper/SqlServerMapper.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.citygis.mapper.SqlServiceMapper">
+
+    <select id="getAll" resultType="com.citygis.pojo.SqlService">
+        select * from test1
+    </select>
+
+</mapper>