代码之家  ›  专栏  ›  技术社区  ›  Cybrus Simon Germain

使用Maven的spring安全依赖性问题

  •  1
  • Cybrus Simon Germain  · 技术社区  · 7 年前

    pom.xml 两种不同的依赖关系:

          <dependency>
               <groupId>org.springframework.security</groupId>
               <artifactId>spring-security-web</artifactId>
               <version>4.0.3.RELEASE</version>
          </dependency>
    
          <dependency>
               <groupId>org.springframework.security</groupId>
               <artifactId>spring-security-config</artifactId>
               <version>4.0.3.RELEASE</version>
          </dependency>
    

    我命令maven clean package mvn spring-boot:run 要获取以下错误消息:

    Java语言lang.IllegalAccessError:试图访问方法org。springframework。果心转换支持DefaultConversionService。addCollectionConverters(Lorg/springframework/core/convert/converter/ConverterRegistry;)V来自班级组织。springframework。靴子绑定RelaxedConversionService

    main Program.java 文件

    主要的 功能如下:

      public static void main(String[] args) {
            SpringApplication.run(Program.class, args);
    }
    

    注意事项和推测

    这个文件是从我在网上读过的各种教程中编译而来的,当我把所有的东西都集中到一起时,我继续往下说。

    公司网络 如果有本地存储库,则某些依赖项可能不是最新版本或可用的最新版本。中的某个地方可能存在版本不匹配 pom ,但我似乎找不到。

    重新创建错误 ,复制
    如果重建失败,我只能假设其中一个包已损坏或损坏(我在本地存储库中遇到过几次坏包)。

    我的 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    
    <modelVersion>4.0.0</modelVersion>
    <groupId>ssp</groupId>
    <artifactId>sspserver</artifactId>
    <version>1.0</version>
    
    <packaging>jar</packaging>
    
    <properties>
        <java.version>1.8</java.version>
    </properties>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
            <version>1.5.6.RELEASE</version>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
            <version>1.5.6.RELEASE</version>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.5.6.RELEASE</version>
        </dependency>
    
        <dependency>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.3</version>
        </dependency>
        
        <!-- Local jars -->
        
        <dependency>
            <groupId>SSPClient</groupId>
            <artifactId>SSPClient</artifactId>
            <scope>system</scope>
            <version>1.0.0</version>
            <systemPath>${basedir}\lib\SSPClient.jar</systemPath>
        </dependency>
    
        <dependency>
            <groupId>smp8</groupId>
            <artifactId>smp8</artifactId>
            <scope>system</scope>
            <version>1.0.0</version>
            <systemPath>${basedir}\lib\smp8.jar</systemPath>
        </dependency>
    
    </dependencies>
    
    <build>
        <finalName>sspserver</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>1.5.6.RELEASE</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    </project>
    

    整个堆栈跟踪:

    java.lang.IllegalAccessError: tried to access method org.springframework.core.convert.support.DefaultConversionService.addCollectionConverters(Lorg/springframework/core/convert/converter/ConverterRegistry;)V from class org.springframework.boot.bind.RelaxedConversionService
    at org.springframework.boot.bind.RelaxedConversionService.<init>(RelaxedConversionService.java:52)
    at org.springframework.boot.bind.RelaxedDataBinder.modifyProperties(RelaxedDataBinder.java:148)
    at org.springframework.boot.bind.RelaxedDataBinder.doBind(RelaxedDataBinder.java:128)
    at org.springframework.validation.DataBinder.bind(DataBinder.java:715)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:272)
    at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.bindToSpringApplication(ConfigFileApplicationListener.java:241)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:197)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:325)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:296)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
    at cpssp.Program.main(Program.java:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
    
    1 回复  |  直到 2 年前
        1
  •  0
  •   mkrieger1    2 年前

    spring-security-* 具有 spring-boot .

    相反,我需要使用:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>1.5.6.RELEASE</version>
        </dependency>