Jeecg boot —— jeecg-cloud-nacos cannot start with java.lang.IllegalArgumentException

22 Views Asked by At

I try to run this project but nacos cannot work with follow:

package com.alibaba.nacos;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletResponse;

/**
 * Nacos 启动类
 *
 * @author zyf
 */
@SpringBootApplication(scanBasePackages = "com.alibaba.nacos")
@ServletComponentScan
@EnableScheduling
public class JeecgNacosApplication {

    /** 是否单机模式启动 */
    private static String standalone = "true";
    /** 是否开启鉴权 */
    private static String enabled = "false";

    public static void main(String[] args) {
        System.setProperty("nacos.standalone", standalone);
        System.setProperty("nacos.core.auth.enabled", enabled);
        System.setProperty("server.tomcat.basedir", "logs");
        // 自定义启动端口号
        System.setProperty("server.port", "8848");
        SpringApplication.run(JeecgNacosApplication.class, args);
    }

    /**
     * 默认跳转首页
     *
     * @param model
     * @return
     */
    @GetMapping("/")
    public String index(Model model, HttpServletResponse response) {
        // 视图重定向 - 跳转
        return "/nacos";
    }
}

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>jeecg-cloud-nacos</artifactId>
    <name>jeecg-cloud-nacos</name>
    <description>nacos启动模块</description>
    <!-- <version>3.6.2</version> -->
    <version>3.5.1</version>

    <!-- Nacos2不支持springboot2.6.6  -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.5.RELEASE</version>
        <!-- <version>2.7.10</version> -->
        <relativePath />
    </parent>

    <repositories>
        <repository>
            <id>aliyun</id>
            <name>aliyun Repository</name>
            <url>https://maven.aliyun.com/repository/public</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>jeecg</id>
            <name>jeecg Repository</name>
            <url>https://maven.jeecg.org/nexus/content/repositories/jeecg</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <properties>
        <log4j2.version>2.17.0</log4j2.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jeecgframework.nacos</groupId>
            <artifactId>nacos-naming</artifactId>
            <version>2.0.4</version>
        </dependency>
        <dependency>
            <groupId>org.jeecgframework.nacos</groupId>
            <artifactId>nacos-istio</artifactId>
            <version>2.0.4</version>
        </dependency>
        <dependency>
            <groupId>org.jeecgframework.nacos</groupId>
            <artifactId>nacos-config</artifactId>
            <version>2.0.4</version>
        </dependency>
        <dependency>
            <groupId>org.jeecgframework.nacos</groupId>
            <artifactId>nacos-console</artifactId>
            <version>2.0.4</version>
        </dependency>
        <!-- <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jeecgframework.nacos</groupId>
            <artifactId>nacos-naming</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.jeecgframework.nacos</groupId>
            <artifactId>nacos-istio</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.jeecgframework.nacos</groupId>
            <artifactId>nacos-config</artifactId>
            <version>2.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.jeecgframework.nacos</groupId>
            <artifactId>nacos-console</artifactId>
            <version>2.2.3</version>
        </dependency> -->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

application.properties:

server.servlet.contextPath=/nacos
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
server.tomcat.basedir=
spring.datasource.platform=mysql
db.num=1
db.password.0=${MYSQL-PWD:root}
db.url.0=jdbc:mysql://${MYSQL-HOST:localhost}:${MYSQL-PORT:3306}/${MYSQL-DB:rc_nacos}?characterEncoding=utf8 &
connectTimeout=1000 &
socketTimeout=3000 &
autoReconnect=true &
useUnicode=true &
useSSL=false &
serverTimezone=UTC &
allowPublicKeyRetrieval=true
db.user.0=${MYSQL-USER:root}
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
nacos.core.auth.caching.enabled=true
nacos.core.auth.default.token.expire.seconds=18000
nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
nacos.core.auth.enabled=false
nacos.core.auth.system.type=nacos
nacos.istio.mcp.server.enabled=false
nacos.naming.empty-service.auto-clean=true
nacos.naming.empty-service.clean.initial-delay-ms=50000
nacos.naming.empty-service.clean.period-time-ms=30000
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
nacos.standalone=true

application.yml:

server:
  servlet:
    contextPath: /nacos
  tomcat:
    accesslog:
      enabled: true
      pattern: '%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i'
    basedir: ''
spring:
  datasource:
    platform: mysql
db:
  num: 1
  password:
    '0': ${MYSQL-PWD:root}
  url:
    # 本地
    '0': jdbc:mysql://${MYSQL-HOST:localhost}:${MYSQL-PORT:3306}/${MYSQL-DB:rc_nacos}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
  user:
    '0': ${MYSQL-USER:root}
management:
  metrics:
    export:
      elastic:
        enabled: false
      influx:
        enabled: false
nacos:
  core:
    auth:
      caching:
        enabled: true
      default:
        token:
          expire:
            seconds: 18000
          secret:
            key: SecretKey012345678901234567890123456789012345678901234567890123456789
      enabled: false
      system:
        type: nacos
  istio:
    mcp:
      server:
        enabled: false
  naming:
    empty-service:
      auto-clean: true
      clean:
        initial-delay-ms: 50000
        period-time-ms: 30000
  security:
    ignore:
      urls: /,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
  standalone: true

and the exception info :

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/ASUS/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/ASUS/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Exception in thread "main" java.lang.IllegalArgumentException: Cannot instantiate interface org.springframework.context.ApplicationListener : org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor
        at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:449)
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:431)
        at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:424)
        at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:268)
        at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:246)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
        at com.alibaba.nacos.JeecgNacosApplication.main(JeecgNacosApplication.java:35)
Caused by: java.lang.IllegalArgumentException: class org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor is not assignable to interface org.springframework.context.ApplicationListener  
        at org.springframework.util.Assert.assignableCheckFailed(Assert.java:720)
        at org.springframework.util.Assert.isAssignable(Assert.java:651)
        at org.springframework.util.Assert.isAssignable(Assert.java:682)
        at org.springframework.boot.SpringApplication.createSpringFactoriesInstances(SpringApplication.java:443)
        ... 7 more

I have tried updating the dependency versions, but when accessing MySQL in Nacos, it prompts that there are unknown fields (which do not exist in MySQL but are attempted to be retrieved). Therefore, I probably cannot change the dependency versions. Simply put, my current situation is that I need a way to run this program without changing the dependency versions.

0

There are 0 best solutions below