无法决定我应该使用哪个春季启动版本?

时间:2019-01-15 15:15:42

标签: spring maven spring-boot spring-mvc pom.xml

我有一个简单的Spring Boot项目,带有以下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>
<parent>
    <groupId>com.a2i</groupId>
    <artifactId>a2i</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.a2i</groupId>
<artifactId>a2iweb-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>a2iweb-test</name>
<description>Demo project for Spring Boot</description>

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.0.1.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-to-slf4j</artifactId>
            </exclusion>

            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jul-to-slf4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>


    <dependency>
        <groupId>com.a2i</groupId>
        <artifactId>a2i-services</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>2.0.1.RELEASE</version>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>


</dependencies>


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

我的主要应用程序是:-

package com.a2i.restweb;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class A2iwebTestApplication {

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

}

我正在获得

的例外
 :: Spring Boot ::        (v2.0.1.RELEASE)

2019-01-15 20:34:14.288  INFO 2552 --- [           main] com.a2i.restweb.A2iwebTestApplication    : Starting A2iwebTestApplication on DESKTOP-J8KSAEV with PID 2552 (C:\Views\Milestone3\a2iweb-test\target\classes started by dhanr in C:\Views\Milestone3\a2iweb-test)
2019-01-15 20:34:14.288  INFO 2552 --- [           main] com.a2i.restweb.A2iwebTestApplication    : No active profile set, falling back to default profiles: default
2019-01-15 20:34:14.324  INFO 2552 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5223e5ee: startup date [Tue Jan 15 20:34:14 IST 2019]; root of context hierarchy
2019-01-15 20:34:14.764 ERROR 2552 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Error processing condition on org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$TomcatWebSocketConfiguration.websocketContainerCustomizer
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:64) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:179) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:141) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at com.a2i.restweb.A2iwebTestApplication.main(A2iwebTestApplication.java:10) [classes/:na]
Caused by: java.lang.ClassCastException: org.springframework.boot.autoconfigure.condition.ConditionalOnJava$JavaVersion cannot be cast to org.springframework.boot.system.JavaVersion
    at org.springframework.boot.autoconfigure.condition.OnJavaCondition.getMatchOutcome(OnJavaCondition.java:48) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.0.1.RELEASE.jar:2.0.1.RELEASE]
    ... 17 common frames omitted

2019-01-15 20:34:14.765  INFO 2552 --- [           main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5223e5ee: startup date [Tue Jan 15 20:34:14 IST 2019]; root of context hierarchy

通过更改spring boot版本可以解决此错误,但会导致另一个版本为

如果我将版本更改为

a)1.5.10.RELEASE
 错误:-在org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:60)nullpointerException

b)2.1.2。发布

错误:-由以下原因引起:java.lang.NoSuchMethodError:org.springframework.core.KotlinDetector.isKotlinReflectPresent()Z

c)2.0.5。发布

错误:-由以下原因引起:java.lang.NoSuchFieldError:记录器

d)1.5.9。发布

错误:-java.lang.NullPointerException:空 在org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:60)

e)2.0.1.RELEASE

错误:-由以下原因引起:java.lang.ClassCastException:org.springframework.boot.autoconfigure.condition.ConditionalOnJava $ JavaVersion无法转换为org.springframework.boot.system.JavaVersion

1 个答案:

答案 0 :(得分:1)

project-> properties-> maven:-取消选中已解决的依赖关系复选框。

enter image description here