From 8ff8fbd317c29dfd646d70cf40b9753ecc8b4f94 Mon Sep 17 00:00:00 2001 From: XiaoLFeng Date: Wed, 29 Nov 2023 22:12:07 +0800 Subject: [PATCH] =?UTF-8?q?SpringBoot=E9=85=8D=E7=BD=AE=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 9 ++++++++ .../DromStarKotlinApplication.kt | 4 ++++ src/main/resources/application.yml | 7 +++++- .../DromStarKotlinApplicationTests.kt | 22 ++++++++++++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e73485c..4466549 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,10 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-aop + com.fasterxml.jackson.module jackson-module-kotlin @@ -51,6 +55,11 @@ 3.0.3 test + + mysql + mysql-connector-java + 8.0.33 + diff --git a/src/main/kotlin/com/xlf/dromstarkotlin/DromStarKotlinApplication.kt b/src/main/kotlin/com/xlf/dromstarkotlin/DromStarKotlinApplication.kt index 86f5273..ed3a7cd 100644 --- a/src/main/kotlin/com/xlf/dromstarkotlin/DromStarKotlinApplication.kt +++ b/src/main/kotlin/com/xlf/dromstarkotlin/DromStarKotlinApplication.kt @@ -2,8 +2,12 @@ package com.xlf.dromstarkotlin import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +import org.springframework.context.annotation.EnableAspectJAutoProxy +import org.springframework.scheduling.annotation.EnableScheduling @SpringBootApplication +@EnableAspectJAutoProxy +@EnableScheduling class DromStarKotlinApplication fun main(args: Array) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8b13789..2c9eab5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1 +1,6 @@ - +spring: + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.5.190:3306 + username: dormstar + password: 114477225588 \ No newline at end of file diff --git a/src/test/kotlin/com/xlf/dromstarkotlin/DromStarKotlinApplicationTests.kt b/src/test/kotlin/com/xlf/dromstarkotlin/DromStarKotlinApplicationTests.kt index 4c65182..28ff68b 100644 --- a/src/test/kotlin/com/xlf/dromstarkotlin/DromStarKotlinApplicationTests.kt +++ b/src/test/kotlin/com/xlf/dromstarkotlin/DromStarKotlinApplicationTests.kt @@ -2,12 +2,32 @@ package com.xlf.dromstarkotlin import org.junit.jupiter.api.Test import org.springframework.boot.test.context.SpringBootTest +import java.util.* @SpringBootTest class DromStarKotlinApplicationTests { - @Test fun contextLoads() { + var token = (Date().time/1000).toString() + val random = Random() + // 判定随机范围 + var i: Int + var j = 0 + while (j++ < 3) { + val x: Int = if(j == 1 || j == 2) 6 else 10 + token += "-" + i = 0 + while (i < x) { + if (random.nextBoolean()) { + token += random.nextInt(10) + } else { + token += random.nextInt(97, 123).toChar() + } + i++ + } + } + println(token) + assert(true) } }