8.4 Spring Boot集成Kotlin混合Java开发

8.4 Spring Boot集成Kotlin混合Java开发

本章介绍Spring Boot集成Kotlin混合Java开发一个完整的spring boot应用:Restfeel,一个企业级的Rest API接口测试平台(在开源工程restfiddle[1]基础上开发而来)。

系统技术框架

编程语言:Java,Kotlin

数据库:Mongo

Spring框架:Spring data jpa,Spring data mongodb

前端:jquery,requireJS,

工程构建工具:Gradle

Kotlin简介

Kotlin是一种优雅的语言,是JetBrains公司开发的静态类型JVM语言,与Java无缝集成。与Java相比,Kotlin的语法更简洁、更具表达性,而且提供了更多的特性,比如,高阶函数、操作符重载、字符串模板。它与Java高度可互操作,可以同时用在一个项目中。这门语言的目标是:

  • 创建一种兼容Java的语言
  • 编译速度至少同Java一样快
  • 比Java更安全,能够静态检测常见的陷阱。如:引用空指针
  • 比Java更简洁,通过支持 variable type inference,higher-order functions (closures),extension functions,mixins and first-class delegation 等实现。
  • 比最成熟的竞争者Scala还简单

Kotlin不像Scala另起炉灶,将类库,尤其是集合类都自己来了一遍。kotlin是对现有java的增强,通过扩展方法给java提供了很多诸如fp之类的特性,但同时始终保持对java的兼容。这也是是kotlin官网首页重点强调的:

100% interoperable with Java™。

Kotlin和Scala很像,对于用惯了Scala的人来说用起来很顺手,对于喜欢函数式的开发者,Kotlin是个不错的选择。有个小点,像Groovy动态类型就不用说了,Scala函数最后返回值都可以省去return,但是不晓得为啥Kotlin对return情有独钟。

另外,Kotlin可以编译成Java字节码,也可以编译成JavaScript,在没有JVM的环境运行。

Kotlin创建类的方式与Java类似,比如下面的代码创建了一个有三个属性的Person类:

class Person{
    var name: String = ""
    var age: Int = 0
    var sex: String? = null
}

可以看到,Kotlin的变量声明方式略有些不同。在Kotline中,声明变量必须使用关键字var,而如果要创建一个只读/只赋值一次的变量,则需要使用val代替它。

Kotlin对函数式编程的实现恰到好处

一个函数指针的例子:

/**
 * "Callable References" or "Feature Literals", i.e. an ability to pass
 * named functions or properties as values. Users often ask
 * "I have a foo() function, how do I pass it as an argument?".
 * The answer is: "you prefix it with a `::`".
 */

fun main(args: Array<String>) {
    val numbers = listOf(1, 2, 3)
    println(numbers.filter(::isOdd))
}


fun isOdd(x: Int) = x % 2 != 0

运行结果: [1, 3]

再看一个复合函数的例子。看了下面的复合函数的例子,你会发现Kotlin的FP的实现相当简洁。(跟纯数学的表达式,相当接近了)

/**
 * The composition function return a composition of two functions passed to it:
 * compose(f, g) = f(g(*)).
 * Now, you can apply it to callable references.
 */

fun main(args: Array<String>) {
    val oddLength = compose(::isOdd, ::length)
    val strings = listOf("a", "ab", "abc")
    println(strings.filter(oddLength))
}

fun isOdd(x: Int) = x % 2 != 0
fun length(s: String) = s.length

fun <A, B, C> compose(f: (B) -> C, g: (A) -> B): (A) -> C {
    return { x -> f(g(x)) }
}

运行结果: [a,abc]

简单说明下
val oddLength = compose(::isOdd, ::length)
    val strings = listOf("a", "ab", "abc")
    println(strings.filter(oddLength))

这就是数学中,复合函数的定义:

h = h(f(g))

g: A->B
f: B->C
h: A->C

g(A)=B
h(A) = f(B) = f(g(A)) = C

只是代码中的写法是:

h=compose( f, g )
h=compose( f(g(A)), g(A) )

关于Kotlin,官网有一个非常好的交互式Kotlin学习教程:

http://try.kotlinlang.org/

想深入语言实现细节的,可以直接参考github源码[3]。

Spring Boot集成 Kotlin

1.build.gradle中添加kotlin相关依赖

使用插件

apply {
    plugin "kotlin"
    plugin "kotlin-spring"
    plugin "kotlin-jpa"
    plugin "org.springframework.boot"
    plugin 'java'
    plugin 'eclipse'
    plugin 'idea'
    plugin 'war'
    plugin 'maven'
}

构建时插件依赖

buildscript {
    ext {
        kotlinVersion = '1.1.0'
        springBootVersion = '1.5.2.RELEASE'
    }

    dependencies {
        classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlinVersion"
        classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "http://oss.jfrog.org/artifactory/oss-release-local" }
        maven { url "http://jaspersoft.artifactoryonline.com/jaspersoft/jaspersoft-repo/" }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }

    }
}

编译时jar包依赖

dependencies {
    compile("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
    compile("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
    compile("com.fasterxml.jackson.module:jackson-module-kotlin:2.8.4")

    ...

}
2.配置源码目录sourceSets
sourceSets {
    main {
        kotlin { srcDir "src/main/kotlin" }
        java { srcDir "src/main/java" }
    }
    test {
        kotlin { srcDir "src/test/kotlin" }
        java { srcDir "src/test/java" }
    }
}
```

指定kotlin,java源码放置目录。让java的归java,Kotlin的归Kotlin。这样区分开来。这个跟scala的插件实现方式上有点区别。scala的插件,是允许你把scala,java代码随便放,插件会自动寻找scala代码编译。


整个工程大目录如下图所示:



![](http://upload-images.jianshu.io/upload_images/1233356-20285f52eb50f486.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)




#####3.写Kotlin代码

Entity实体类

```
package com.restfeel.entity

import org.bson.types.ObjectId
import org.springframework.data.mongodb.core.mapping.Document
import java.util.*
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.Version

@Document(collection = "blog") // 如果不指定collection,默认遵从命名规则
class Blog {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    var id: String = ObjectId.get().toString()
    @Version
    var version: Long = 0
    var title: String = ""
    var content: String = ""
    var author: String = ""
    var gmtCreated: Date = Date()
    var gmtModified: Date = Date()
    var isDeleted: Int = 0 //1 Yes 0 No
    var deletedDate: Date = Date()
    override fun toString(): String {
        return "Blog(id='$id', version=$version, title='$title', content='$content', author='$author', gmtCreated=$gmtCreated, gmtModified=$gmtModified, isDeleted=$isDeleted, deletedDate=$deletedDate)"
    }

}


```

Service类

```
package com.restfeel.service

import com.restfeel.entity.Blog
import org.springframework.data.mongodb.repository.MongoRepository
import org.springframework.data.mongodb.repository.Query
import org.springframework.data.repository.query.Param

interface BlogService : MongoRepository<Blog, String> {

    @Query("{ 'title' : ?0 }")
    fun findByTitle(@Param("title") title: String): Iterable<Blog>

}

```


Controller类

```
package com.restfeel.controller

import com.restfeel.entity.Blog
import com.restfeel.service.BlogService
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.security.core.userdetails.UserDetails
import org.springframework.stereotype.Controller
import org.springframework.transaction.annotation.Propagation
import org.springframework.transaction.annotation.Transactional
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.ResponseBody
import java.util.*
import javax.servlet.http.HttpServletRequest

/**
 * 文章列表,写文章的Controller
 * @author Jason Chen  2017/3/31 01:10:16
 */

@Controller
@EnableAutoConfiguration
@ComponentScan
@Transactional(propagation = Propagation.REQUIRES_NEW)
class BlogController(val blogService: BlogService) {
    @GetMapping("/blogs.do")
    fun listAll(model: Model): String {
        val authentication = SecurityContextHolder.getContext().authentication
        model.addAttribute("currentUser", if (authentication == null) null else authentication.principal as UserDetails)
        val allblogs = blogService.findAll()
        model.addAttribute("blogs", allblogs)
        return "jsp/blog/list"
    }

    @PostMapping("/saveBlog")
    @ResponseBody
    fun saveBlog(blog: Blog, request: HttpServletRequest):Blog {
        blog.author = (request.getSession().getAttribute("currentUser") as UserDetails).username
        return blogService.save(blog)
    }

    @GetMapping("/goEditBlog")
    fun goEditBlog(@RequestParam(value = "id") id: String, model: Model): String {
        model.addAttribute("blog", blogService.findOne(id))
        return "jsp/blog/edit"
    }

    @PostMapping("/editBlog")
    @ResponseBody
    fun editBlog(blog: Blog, request: HttpServletRequest) :Blog{
        blog.author = (request.getSession().getAttribute("currentUser") as UserDetails).username
        blog.gmtModified = Date()
        blog.version = blog.version + 1
        return blogService.save(blog)
    }

    @GetMapping("/blog")
    fun blogDetail(@RequestParam(value = "id") id: String, model: Model): String {
        model.addAttribute("blog", blogService.findOne(id))
        return "jsp/blog/detail"
    }

    @GetMapping("/listblogs")
    @ResponseBody
    fun listblogs(model: Model) = blogService.findAll()

    @GetMapping("/findBlogByTitle")
    @ResponseBody
    fun findBlogByTitle(@RequestParam(value = "title") title: String) = blogService.findByTitle(title)

}

```



对应的前端代码,这里就不多说了。可以参考工程源代码[4]。



SpringBoot的启动类: 我们用Kotlin写SpringBoot的启动类:

```
package com.restfeel

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.SpringApplication
import org.springframework.core.env.Environment

/**
 * Created by jack on 2017/3/29.
 * @author jack
 * @date 2017/03/29
 */
@RestFeelBoot
class RestFeelApplicationKotlin : CommandLineRunner {
    @Autowired
    private val env: Environment? = null

    override fun run(vararg args: String?) {
        println("RESTFEEL 启动完毕")
        println("应用地址:" + env?.getProperty("application.host-uri"))
    }
}

fun main(args: Array<String>) {
    SpringApplication.run(RestFeelApplicationKotlin::class.java, *args)
}



```



其中,@RestFeelBoot是自定义注解,代码如下:

```
package com.restfeel;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Created by jack on 2017/3/23.
 *
 * @author jack
 * @date 2017/03/23
 */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Configuration
@EnableAutoConfiguration
@ComponentScan
public @interface RestFeelBoot {
    Class<?>[] exclude() default {};
}

```


#####运行测试

命令行输入gradle bootRun,运行应用。 访问 http://127.0.0.1:5678/blogs.do 

文章列表
![](http://upload-images.jianshu.io/upload_images/1233356-365b79713f187cc3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)




写文章

![](http://upload-images.jianshu.io/upload_images/1233356-87929f0b83a43ad8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

阅读文章



![](http://upload-images.jianshu.io/upload_images/1233356-4b12e505588c6b3f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)




##小结

本章示例工程源代码:

https://github.com/Jason-Chen-2017/restfeel/tree/restfeel_kotlin_2017.5.6




参考资料:
1.https://github.com/AnujaK/restfiddle
2.http://www.jianshu.com/c/498ebcfd27ad
3.https://github.com/JetBrains/kotlin
4.https://github.com/Jason-Chen-2017/restfeel/tree/restfeel_kotlin_2017.5.6
C:\Users\Lenovo\.jdks\corretto-1.8.0_462\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-Dmanagement.endpoints.jmx.exposure.include=*" "-javaagent:D:\IntelliJ IDEA 2025.2\lib\idea_rt.jar=2427" -Dfile.encoding=UTF-8 -classpath "C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\charsets.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\access-bridge-64.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\cldrdata.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\dnsns.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\jaccess.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\jfxrt.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\localedata.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\nashorn.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\sunec.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\sunjce_provider.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\sunmscapi.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\sunpkcs11.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\ext\zipfs.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\jce.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\jfr.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\jfxswt.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\jsse.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\management-agent.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\resources.jar;C:\Users\Lenovo\.jdks\corretto-1.8.0_462\jre\lib\rt.jar;E:\前后端代码\shigong-new_20250810 (2)\shigong-new - 副本\ruoyi-modules\activiti\target\classes;C:\JAVA\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-discovery\2021.0.5.0\spring-cloud-starter-alibaba-nacos-discovery-2021.0.5.0.jar;C:\JAVA\repository\com\alibaba\cloud\spring-cloud-alibaba-commons\2021.0.5.0\spring-cloud-alibaba-commons-2021.0.5.0.jar;C:\JAVA\repository\com\alibaba\nacos\nacos-client\2.2.0\nacos-client-2.2.0.jar;C:\JAVA\repository\com\alibaba\nacos\nacos-auth-plugin\2.2.0\nacos-auth-plugin-2.2.0.jar;C:\JAVA\repository\com\alibaba\nacos\nacos-encryption-plugin\2.2.0\nacos-encryption-plugin-2.2.0.jar;C:\JAVA\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\JAVA\repository\org\apache\httpcomponents\httpasyncclient\4.1.5\httpasyncclient-4.1.5.jar;C:\JAVA\repository\org\apache\httpcomponents\httpcore-nio\4.4.16\httpcore-nio-4.4.16.jar;C:\JAVA\repository\io\prometheus\simpleclient\0.15.0\simpleclient-0.15.0.jar;C:\JAVA\repository\io\prometheus\simpleclient_tracer_otel\0.15.0\simpleclient_tracer_otel-0.15.0.jar;C:\JAVA\repository\io\prometheus\simpleclient_tracer_common\0.15.0\simpleclient_tracer_common-0.15.0.jar;C:\JAVA\repository\io\prometheus\simpleclient_tracer_otel_agent\0.15.0\simpleclient_tracer_otel_agent-0.15.0.jar;C:\JAVA\repository\org\yaml\snakeyaml\1.30\snakeyaml-1.30.jar;C:\JAVA\repository\com\alibaba\spring\spring-context-support\1.0.11\spring-context-support-1.0.11.jar;C:\JAVA\repository\org\springframework\cloud\spring-cloud-commons\3.1.7\spring-cloud-commons-3.1.7.jar;C:\JAVA\repository\org\springframework\security\spring-security-crypto\5.7.9\spring-security-crypto-5.7.9.jar;C:\JAVA\repository\org\springframework\cloud\spring-cloud-context\3.1.7\spring-cloud-context-3.1.7.jar;C:\JAVA\repository\com\alibaba\cloud\spring-cloud-starter-alibaba-nacos-config\2021.0.5.0\spring-cloud-starter-alibaba-nacos-config-2021.0.5.0.jar;C:\JAVA\repository\org\slf4j\slf4j-api\1.7.36\slf4j-api-1.7.36.jar;C:\JAVA\repository\com\mysql\mysql-connector-j\8.0.33\mysql-connector-j-8.0.33.jar;E:\前后端代码\shigong-new_20250810 (2)\shigong-new - 副本\ruoyi-common\ruoyi-common-core\target\classes;C:\JAVA\repository\org\springframework\cloud\spring-cloud-starter-openfeign\3.1.8\spring-cloud-starter-openfeign-3.1.8.jar;C:\JAVA\repository\org\springframework\cloud\spring-cloud-openfeign-core\3.1.8\spring-cloud-openfeign-core-3.1.8.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-aop\2.7.13\spring-boot-starter-aop-2.7.13.jar;C:\JAVA\repository\org\aspectj\aspectjweaver\1.9.7\aspectjweaver-1.9.7.jar;C:\JAVA\repository\io\github\openfeign\form\feign-form-spring\3.8.0\feign-form-spring-3.8.0.jar;C:\JAVA\repository\io\github\openfeign\form\feign-form\3.8.0\feign-form-3.8.0.jar;C:\JAVA\repository\commons-fileupload\commons-fileupload\1.5\commons-fileupload-1.5.jar;C:\JAVA\repository\io\github\openfeign\feign-core\11.10\feign-core-11.10.jar;C:\JAVA\repository\io\github\openfeign\feign-slf4j\11.10\feign-slf4j-11.10.jar;C:\JAVA\repository\org\springframework\cloud\spring-cloud-starter-loadbalancer\3.1.7\spring-cloud-starter-loadbalancer-3.1.7.jar;C:\JAVA\repository\org\springframework\cloud\spring-cloud-loadbalancer\3.1.7\spring-cloud-loadbalancer-3.1.7.jar;C:\JAVA\repository\io\projectreactor\reactor-core\3.4.30\reactor-core-3.4.30.jar;C:\JAVA\repository\org\reactivestreams\reactive-streams\1.0.4\reactive-streams-1.0.4.jar;C:\JAVA\repository\io\projectreactor\addons\reactor-extra\3.4.10\reactor-extra-3.4.10.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-cache\2.7.13\spring-boot-starter-cache-2.7.13.jar;C:\JAVA\repository\com\stoyanr\evictor\1.0.0\evictor-1.0.0.jar;C:\JAVA\repository\org\springframework\spring-context-support\5.3.28\spring-context-support-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-beans\5.3.28\spring-beans-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-context\5.3.28\spring-context-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-aop\5.3.28\spring-aop-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-expression\5.3.28\spring-expression-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-core\5.3.28\spring-core-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-jcl\5.3.28\spring-jcl-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-web\5.3.28\spring-web-5.3.28.jar;C:\JAVA\repository\com\alibaba\transmittable-thread-local\2.14.3\transmittable-thread-local-2.14.3.jar;C:\JAVA\repository\com\github\pagehelper\pagehelper-spring-boot-starter\1.4.7\pagehelper-spring-boot-starter-1.4.7.jar;C:\JAVA\repository\com\github\pagehelper\pagehelper-spring-boot-autoconfigure\1.4.7\pagehelper-spring-boot-autoconfigure-1.4.7.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-validation\2.7.13\spring-boot-starter-validation-2.7.13.jar;C:\JAVA\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.76\tomcat-embed-el-9.0.76.jar;C:\JAVA\repository\org\hibernate\validator\hibernate-validator\6.2.5.Final\hibernate-validator-6.2.5.Final.jar;C:\JAVA\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\JAVA\repository\org\jboss\logging\jboss-logging\3.4.3.Final\jboss-logging-3.4.3.Final.jar;C:\JAVA\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\JAVA\repository\com\fasterxml\jackson\core\jackson-databind\2.13.5\jackson-databind-2.13.5.jar;C:\JAVA\repository\com\alibaba\fastjson2\fastjson2\2.0.39\fastjson2-2.0.39.jar;C:\JAVA\repository\io\jsonwebtoken\jjwt\0.9.1\jjwt-0.9.1.jar;C:\JAVA\repository\javax\xml\bind\jaxb-api\2.3.1\jaxb-api-2.3.1.jar;C:\JAVA\repository\javax\activation\javax.activation-api\1.2.0\javax.activation-api-1.2.0.jar;C:\JAVA\repository\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;C:\JAVA\repository\commons-io\commons-io\2.13.0\commons-io-2.13.0.jar;C:\JAVA\repository\org\apache\poi\poi-ooxml\4.1.2\poi-ooxml-4.1.2.jar;C:\JAVA\repository\org\apache\poi\poi-ooxml-schemas\4.1.2\poi-ooxml-schemas-4.1.2.jar;C:\JAVA\repository\org\apache\xmlbeans\xmlbeans\3.1.0\xmlbeans-3.1.0.jar;C:\JAVA\repository\com\github\virtuald\curvesapi\1.06\curvesapi-1.06.jar;C:\JAVA\repository\org\apache\poi\poi\4.1.2\poi-4.1.2.jar;C:\JAVA\repository\org\apache\commons\commons-collections4\4.4\commons-collections4-4.4.jar;C:\JAVA\repository\org\apache\commons\commons-math3\3.6.1\commons-math3-3.6.1.jar;C:\JAVA\repository\com\zaxxer\SparseBitSet\1.2\SparseBitSet-1.2.jar;C:\JAVA\repository\javax\servlet\javax.servlet-api\4.0.1\javax.servlet-api-4.0.1.jar;C:\JAVA\repository\com\baomidou\mybatis-plus-boot-starter\3.3.0\mybatis-plus-boot-starter-3.3.0.jar;C:\JAVA\repository\com\baomidou\mybatis-plus\3.3.0\mybatis-plus-3.3.0.jar;C:\JAVA\repository\com\baomidou\mybatis-plus-extension\3.3.0\mybatis-plus-extension-3.3.0.jar;C:\JAVA\repository\com\baomidou\mybatis-plus-core\3.3.0\mybatis-plus-core-3.3.0.jar;C:\JAVA\repository\com\baomidou\mybatis-plus-annotation\3.3.0\mybatis-plus-annotation-3.3.0.jar;C:\JAVA\repository\org\apache\httpcomponents\httpclient\4.5.14\httpclient-4.5.14.jar;C:\JAVA\repository\org\apache\httpcomponents\httpmime\4.5.14\httpmime-4.5.14.jar;C:\JAVA\repository\cn\hutool\hutool-all\5.3.4\hutool-all-5.3.4.jar;C:\JAVA\repository\org\apache\httpcomponents\httpcore\4.4.16\httpcore-4.4.16.jar;C:\JAVA\repository\com\drewnoakes\metadata-extractor\2.15.0\metadata-extractor-2.15.0.jar;C:\JAVA\repository\com\adobe\xmp\xmpcore\6.0.6\xmpcore-6.0.6.jar;C:\JAVA\repository\com\belerweb\pinyin4j\2.5.0\pinyin4j-2.5.0.jar;C:\JAVA\repository\commons-beanutils\commons-beanutils\1.9.4\commons-beanutils-1.9.4.jar;C:\JAVA\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;C:\JAVA\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\JAVA\repository\org\locationtech\proj4j\proj4j\1.3.0\proj4j-1.3.0.jar;C:\JAVA\repository\org\locationtech\proj4j\proj4j-epsg\1.3.0\proj4j-epsg-1.3.0.jar;C:\JAVA\repository\org\jsoup\jsoup\1.12.1\jsoup-1.12.1.jar;C:\JAVA\repository\org\freemarker\freemarker\2.3.32\freemarker-2.3.32.jar;E:\前后端代码\shigong-new_20250810 (2)\shigong-new - 副本\ruoyi-common\ruoyi-common-log\target\classes;E:\前后端代码\shigong-new_20250810 (2)\shigong-new - 副本\ruoyi-common\ruoyi-common-security\target\classes;C:\JAVA\repository\org\springframework\spring-webmvc\5.3.28\spring-webmvc-5.3.28.jar;E:\前后端代码\shigong-new_20250810 (2)\shigong-new - 副本\ruoyi-api\ruoyi-api-system\target\classes;E:\前后端代码\shigong-new_20250810 (2)\shigong-new - 副本\ruoyi-common\ruoyi-common-redis\target\classes;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-data-redis\2.7.13\spring-boot-starter-data-redis-2.7.13.jar;C:\JAVA\repository\org\springframework\data\spring-data-redis\2.7.13\spring-data-redis-2.7.13.jar;C:\JAVA\repository\org\springframework\data\spring-data-keyvalue\2.7.13\spring-data-keyvalue-2.7.13.jar;C:\JAVA\repository\org\springframework\data\spring-data-commons\2.7.13\spring-data-commons-2.7.13.jar;C:\JAVA\repository\org\springframework\spring-oxm\5.3.28\spring-oxm-5.3.28.jar;C:\JAVA\repository\redis\clients\jedis\3.8.0\jedis-3.8.0.jar;C:\JAVA\repository\org\apache\commons\commons-pool2\2.11.1\commons-pool2-2.11.1.jar;C:\JAVA\repository\org\gavaghan\geodesy\1.1.3\geodesy-1.1.3.jar;C:\JAVA\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.3\mybatis-spring-boot-starter-2.1.3.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter\2.7.13\spring-boot-starter-2.7.13.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-logging\2.7.13\spring-boot-starter-logging-2.7.13.jar;C:\JAVA\repository\ch\qos\logback\logback-classic\1.2.12\logback-classic-1.2.12.jar;C:\JAVA\repository\ch\qos\logback\logback-core\1.2.12\logback-core-1.2.12.jar;C:\JAVA\repository\org\apache\logging\log4j\log4j-to-slf4j\2.17.2\log4j-to-slf4j-2.17.2.jar;C:\JAVA\repository\org\slf4j\jul-to-slf4j\1.7.36\jul-to-slf4j-1.7.36.jar;C:\JAVA\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-jdbc\2.7.13\spring-boot-starter-jdbc-2.7.13.jar;C:\JAVA\repository\com\zaxxer\HikariCP\4.0.3\HikariCP-4.0.3.jar;C:\JAVA\repository\org\springframework\spring-jdbc\5.3.28\spring-jdbc-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-tx\5.3.28\spring-tx-5.3.28.jar;C:\JAVA\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.3\mybatis-spring-boot-autoconfigure-2.1.3.jar;C:\JAVA\repository\org\mybatis\mybatis\3.5.5\mybatis-3.5.5.jar;C:\JAVA\repository\org\mybatis\mybatis-spring\2.0.5\mybatis-spring-2.0.5.jar;C:\JAVA\repository\org\apache\logging\log4j\log4j-api\2.17.1\log4j-api-2.17.1.jar;C:\JAVA\repository\com\github\pagehelper\pagehelper\5.1.8\pagehelper-5.1.8.jar;C:\JAVA\repository\com\github\jsqlparser\jsqlparser\1.2\jsqlparser-1.2.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-websocket\2.7.13\spring-boot-starter-websocket-2.7.13.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-web\2.7.13\spring-boot-starter-web-2.7.13.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-json\2.7.13\spring-boot-starter-json-2.7.13.jar;C:\JAVA\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.13.5\jackson-datatype-jdk8-2.13.5.jar;C:\JAVA\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.13.5\jackson-datatype-jsr310-2.13.5.jar;C:\JAVA\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.13.5\jackson-module-parameter-names-2.13.5.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-starter-tomcat\2.7.13\spring-boot-starter-tomcat-2.7.13.jar;C:\JAVA\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.76\tomcat-embed-core-9.0.76.jar;C:\JAVA\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.76\tomcat-embed-websocket-9.0.76.jar;C:\JAVA\repository\org\springframework\spring-messaging\5.3.28\spring-messaging-5.3.28.jar;C:\JAVA\repository\org\springframework\spring-websocket\5.3.28\spring-websocket-5.3.28.jar;C:\JAVA\repository\org\projectlombok\lombok\1.18.28\lombok-1.18.28.jar;C:\JAVA\repository\io\minio\minio\8.4.5\minio-8.4.5.jar;C:\JAVA\repository\com\carrotsearch\thirdparty\simple-xml-safe\2.7.1\simple-xml-safe-2.7.1.jar;C:\JAVA\repository\com\google\guava\guava\30.1.1-jre\guava-30.1.1-jre.jar;C:\JAVA\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\JAVA\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\JAVA\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\JAVA\repository\org\checkerframework\checker-qual\3.8.0\checker-qual-3.8.0.jar;C:\JAVA\repository\com\google\errorprone\error_prone_annotations\2.5.1\error_prone_annotations-2.5.1.jar;C:\JAVA\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\JAVA\repository\com\fasterxml\jackson\core\jackson-annotations\2.13.5\jackson-annotations-2.13.5.jar;C:\JAVA\repository\com\fasterxml\jackson\core\jackson-core\2.13.5\jackson-core-2.13.5.jar;C:\JAVA\repository\org\bouncycastle\bcprov-jdk15on\1.69\bcprov-jdk15on-1.69.jar;C:\JAVA\repository\org\apache\commons\commons-compress\1.21\commons-compress-1.21.jar;C:\JAVA\repository\org\xerial\snappy\snappy-java\1.1.8.4\snappy-java-1.1.8.4.jar;C:\JAVA\repository\com\squareup\okhttp3\okhttp\4.9.0\okhttp-4.9.0.jar;C:\JAVA\repository\com\squareup\okio\okio\2.8.0\okio-2.8.0.jar;C:\JAVA\repository\org\jetbrains\kotlin\kotlin-stdlib-common\1.6.21\kotlin-stdlib-common-1.6.21.jar;C:\JAVA\repository\org\jetbrains\kotlin\kotlin-stdlib\1.6.21\kotlin-stdlib-1.6.21.jar;C:\JAVA\repository\org\jetbrains\annotations\13.0\annotations-13.0.jar;C:\JAVA\repository\net\coobird\thumbnailator\0.4.8\thumbnailator-0.4.8.jar;C:\JAVA\repository\org\springframework\cloud\spring-cloud-starter-bootstrap\3.1.7\spring-cloud-starter-bootstrap-3.1.7.jar;C:\JAVA\repository\org\springframework\cloud\spring-cloud-starter\3.1.7\spring-cloud-starter-3.1.7.jar;C:\JAVA\repository\org\springframework\security\spring-security-rsa\1.0.11.RELEASE\spring-security-rsa-1.0.11.RELEASE.jar;C:\JAVA\repository\org\bouncycastle\bcpkix-jdk15on\1.69\bcpkix-jdk15on-1.69.jar;C:\JAVA\repository\org\bouncycastle\bcutil-jdk15on\1.69\bcutil-jdk15on-1.69.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-configuration-processor\2.7.13\spring-boot-configuration-processor-2.7.13.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-devtools\2.7.13\spring-boot-devtools-2.7.13.jar;C:\JAVA\repository\org\springframework\boot\spring-boot\2.7.13\spring-boot-2.7.13.jar;C:\JAVA\repository\org\springframework\boot\spring-boot-autoconfigure\2.7.13\spring-boot-autoconfigure-2.7.13.jar" com.yupont.app.ActivitiApplication 10:13:52.793 [Thread-1] DEBUG org.springframework.boot.devtools.restart.classloader.RestartClassLoader - Created RestartClassLoader org.springframework.boot.devtools.restart.classloader.RestartClassLoader@28b66390 2025-08-21 10:13:53.059 INFO 3976 --- [ restartedMain] c.a.n.client.env.SearchableProperties : properties search order:PROPERTIES->JVM->ENV->DEFAULT_SETTING 2025-08-21 10:13:53.175 INFO 3976 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable 2025-08-21 10:13:53.382 INFO 3976 --- [ restartedMain] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.impl.NacosClientAuthServiceImpl success. 2025-08-21 10:13:53.382 INFO 3976 --- [ restartedMain] c.a.n.p.a.s.c.ClientAuthPluginManager : [ClientAuthPluginManager] Load ClientAuthService com.alibaba.nacos.client.auth.ram.RamClientAuthServiceImpl success. . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.7.13) 2025-08-21 10:14:00.385 WARN 3976 --- [ restartedMain] c.a.c.n.c.NacosPropertySourceBuilder : Ignore the empty nacos configuration and get it based on dataId[null.properties] & group[DEFAULT_GROUP] 2025-08-21 10:14:00.386 INFO 3976 --- [ restartedMain] b.c.PropertySourceBootstrapConfiguration : Located property source: [BootstrapPropertySource {name='bootstrapProperties-null.properties,DEFAULT_GROUP'}] 2025-08-21 10:14:00.399 INFO 3976 --- [ restartedMain] com.yupont.app.ActivitiApplication : No active profile set, falling back to 1 default profile: "default" 2025-08-21 10:14:01.046 INFO 3976 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode 2025-08-21 10:14:01.048 INFO 3976 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode. 2025-08-21 10:14:01.059 INFO 3976 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 3 ms. Found 0 Redis repository interfaces. 2025-08-21 10:14:01.160 WARN 3976 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.yupont.app.*.dao]' package. Please check your configuration. 2025-08-21 10:14:01.199 INFO 3976 --- [ restartedMain] o.s.cloud.context.scope.GenericScope : BeanFactory id=84bfe0a8-a36d-3907-9c5a-a783377777d2 2025-08-21 10:14:01.711 INFO 3976 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2025-08-21 10:14:01.719 INFO 3976 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2025-08-21 10:14:01.719 INFO 3976 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.76] 2025-08-21 10:14:01.867 INFO 3976 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2025-08-21 10:14:01.867 INFO 3976 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1444 ms 2025-08-21 10:14:02.381 WARN 3976 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class 2025-08-21 10:14:02.382 INFO 3976 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2025-08-21 10:14:02.392 INFO 3976 --- [ restartedMain] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2025-08-21 10:14:02.410 ERROR 3976 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the classpath. If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active). 2025-08-21 10:14:02.412 WARN 3976 --- [ Thread-12] c.a.nacos.common.notify.NotifyCenter : [NotifyCenter] Start destroying Publisher 2025-08-21 10:14:02.412 WARN 3976 --- [ Thread-5] c.a.n.common.http.HttpClientBeanHolder : [HttpClientBeanHolder] Start destroying common HttpClient 2025-08-21 10:14:02.412 WARN 3976 --- [ Thread-12] c.a.nacos.common.notify.NotifyCenter : [NotifyCenter] Destruction of the end 进程已结束,退出代码为 0
最新发布
08-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值