elunez / eladmin-mp

eladmin mybatis-plus版本:项目基于 Spring Boot 2.6.4 、MyBatis-Plus、Spring Security、Redis、Vue的前后端分离的后台管理系统, 权限控制采用 RBAC,支持数据字典与数据权限管理,支持一键生成前后端代码,支持动态路由
https://eladmin.vip/demo
Apache License 2.0
425 stars 160 forks source link

后端项目无法启动 #26

Closed fineday009 closed 8 months ago

fineday009 commented 1 year ago

Jdk1.8 环境,macos

OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
Connected to the target VM, address: '127.0.0.1:56923', transport: 'socket'
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
       _                 _           _
      | |               | |         (_)
   ___| |______ __ _  __| |_ __ ___  _ _ __
  / _ | |______/ _` |/ _` | '_ ` _ \| | '_ \
 |  __| |     | (_| | (_| | | | | | | | | | |
  \___|_|      \__,_|\__,_|_| |_| |_|_|_| |_|

 :: Spring Boot ::       (v2.6.4)
elAdmin- 2023-08-31 15:52:55 [main] INFO  me.zhengjie.AppRun - Starting AppRun using Java 15 on MacBook-Pro-5.local with PID 91774 (/Users/iceewei/projects/fullstack/eladmin-mp/eladmin/eladmin-system/target/classes started by iceewei in /Users/iceewei/projects/fullstack/eladmin-mp/eladmin)
elAdmin- 2023-08-31 15:52:55 [main] INFO  me.zhengjie.AppRun - The following 1 profile is active: "dev"
elAdmin- 2023-08-31 15:52:57 [main] INFO  o.s.b.w.e.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8000 (http)
elAdmin- 2023-08-31 15:52:57 [main] INFO  o.a.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8000"]
elAdmin- 2023-08-31 15:52:57 [main] INFO  o.a.catalina.core.StandardService - Starting service [Tomcat]
elAdmin- 2023-08-31 15:52:57 [main] INFO  o.a.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.58]
elAdmin- 2023-08-31 15:52:57 [main] INFO  o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext
elAdmin- 2023-08-31 15:52:57 [main] INFO  o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 2019 ms
Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
elAdmin- 2023-08-31 15:52:57 [main] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appController' defined in file [/Users/iceewei/projects/fullstack/eladmin-mp/eladmin/eladmin-system/target/classes/me/zhengjie/modules/mnt/rest/AppController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'appServiceImpl' defined in file [/Users/iceewei/projects/fullstack/eladmin-mp/eladmin/eladmin-system/target/classes/me/zhengjie/modules/mnt/service/impl/AppServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appMapper' defined in file [/Users/iceewei/projects/fullstack/eladmin-mp/eladmin/eladmin-system/target/classes/me/zhengjie/modules/mnt/mapper/AppMapper.class]: Cannot resolve reference to bean 'sqlSessionTemplate' while setting bean property 'sqlSessionTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionTemplate' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is 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
elAdmin- 2023-08-31 15:52:57 [main] INFO  o.a.catalina.core.StandardService - Stopping service [Tomcat]
elAdmin- 2023-08-31 15:52:58 [main] INFO  o.s.b.a.l.ConditionEvaluationReportLoggingListener - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
elAdmin- 2023-08-31 15:52:58 [main] ERROR 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 (the profiles dev are currently active).

Disconnected from the target VM, address: '127.0.0.1:56923', transport: 'socket'

Process finished with exit code 1

我的配置文件。 配置文件里我改动了2处。第1处是mysql的3306端口,我改为了3350;第2处是mysql的password,我改为了root,其他没有改动。

# Sql日志
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

#配置数据源
spring:
  datasource:
    druid:
      db-type: com.alibaba.druid.pool.DruidDataSource
      driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
      url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3350}/${DB_NAME:eladmin}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
      username: ${DB_USER:root}
      password: ${DB_PWD:root}
      # 初始连接数
      initial-size: 5
      # 最小连接数
      min-idle: 15
      # 最大连接数
      max-active: 30
      # 超时时间(以秒数为单位)
      remove-abandoned-timeout: 180
      # 获取连接超时时间
      max-wait: 3000
      # 连接有效性检测时间
      time-between-eviction-runs-millis: 60000
      # 连接在池中最小生存的时间
      min-evictable-idle-time-millis: 300000
      # 连接在池中最大生存的时间
      max-evictable-idle-time-millis: 900000
      # 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
      test-while-idle: true
      # 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
      test-on-borrow: true
      # 是否在归还到池中前进行检验
      test-on-return: false
      # 检测连接是否有效
      validation-query: select 1
      # 配置监控统计
      webStatFilter:
        enabled: true
      stat-view-servlet:
        enabled: true
        url-pattern: /druid/*
        reset-enable: false
      filter:
        stat:
          enabled: true
          # 记录慢SQL
          log-slow-sql: true
          slow-sql-millis: 1000
          merge-sql: true
        wall:
          config:
            multi-statement-allow: true

# 登录相关配置
login:
  #  是否限制单用户登录
  single-login: false
  # Redis用户登录缓存配置
  user-cache:
    # 存活时间/秒
    idle-time: 21600
  #  验证码
  login-code:
    #  验证码类型配置 查看 LoginProperties 类
    code-type: arithmetic
    #  登录图形验证码有效时间/分钟
    expiration: 2
    #  验证码高度
    width: 111
    #  验证码宽度
    height: 36
    # 内容长度
    length: 2
    # 字体名称,为空则使用默认字体
    font-name:
    # 字体大小
    font-size: 25

#jwt
jwt:
  header: Authorization
  # 令牌前缀
  token-start-with: Bearer
  # 必须使用最少88位的Base64对该令牌进行编码
  base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI=
  # 令牌过期时间 此处单位/毫秒 ,默认4小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html
  token-validity-in-seconds: 14400000
  # 在线用户key
  online-key: "online-token:"
  # 验证码
  code-key: "captcha-code:"
  # token 续期检查时间范围(默认30分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
  detect: 1800000
  # 续期时间范围,默认1小时,单位毫秒
  renew: 3600000

#是否允许生成代码,生产环境设置为false
generator:
  enabled: true

#是否开启 swagger-ui
swagger:
  enabled: true

# 文件存储路径
file:
  mac:
    path: ~/file/
    avatar: ~/avatar/
  linux:
    path: /home/eladmin/file/
    avatar: /home/eladmin/avatar/
  windows:
    path: C:\eladmin\file\
    avatar: C:\eladmin\avatar\
  # 文件大小 /M
  maxSize: 100
  avatarMaxSize: 5
fineday009 commented 1 year ago

发现用命令启动是ok的,像这样:

java -jar eladmin-system/target/eladmin-system-1.1.jar --spring.profiles.active=dev

但是用idea的按钮去Run或者Debug就有上面的问题了。

RandolphChin commented 12 months ago

你用的 JDK 15,可能版本太高了,降降版本,JDK 8 没问题

elunez commented 8 months ago

支持 jdk8、11,高版本没试过