Проблемы с зависимостями Spring-boot

Я пытаюсь обновить наш проект с Spring-boot 1.4.3 до 2.0.4.RELEASE;

Вот мой текущий файл pom.xml:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>SpreadSheetUploadWeb</groupId>
    <artifactId>SpreadSheetUploadWeb</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.4.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
        <spring.version>4.3.9.RELEASE</spring.version>
        <spring.boot.version>2.0.4.RELEASE</spring.boot.version>
        <db2.driver.version>10.5.9</db2.driver.version>
        <spring.batch.version>3.0.8.RELEASE</spring.batch.version>
        <tomcat.version>8.5.6</tomcat.version>
        <poi.version>3.15</poi.version>
        <sonar.coverage.exclusions>**/BlueCostSpreadsheetUploadWebApplication.java</sonar.coverage.exclusions>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring.boot.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>${spring.boot.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- POI dependencies -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>${poi.version}</version>
        </dependency>

        <!-- DB2 dependencies -->
        <dependency>
            <groupId>com.ibm.db2.jcc</groupId>
            <artifactId>db2jcc_license_cisuz</artifactId>
            <version>${db2.driver.version}</version>
        </dependency>
        <dependency>
            <groupId>com.ibm.db2.jcc</groupId>
            <artifactId>db2jcc4</artifactId>
            <version>${db2.driver.version}</version>
        </dependency>

        <!-- HSQLDB dependencies -->
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>2.4.0</version><!--$NO-MVN-MAN-VER$ -->
            <scope>test</scope>
        </dependency>

        <!-- JJD adding to make REST Test cases work 
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20180130</version>
        </dependency -->

        <!-- JJD adding Sonarqube dependency  -->
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.4.0.905</version>
            <type>pom</type>
        </dependency>   
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            </dependency>
        <!-- JJD The next two are for generating Swagger Documents for REST api documentation -->
        <dependency>     
            <groupId>io.springfox</groupId>     
            <artifactId>springfox-swagger2</artifactId>     
            <version>2.9.2</version>    
        </dependency>    
        <dependency>     
            <groupId>io.springfox</groupId>     
            <artifactId>springfox-swagger-ui</artifactId>     
            <version>2.9.2</version>    
        </dependency>           
    </dependencies>

    <build>
        <finalName>bluecost-spreadsheet-web</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring.boot.version}</version>
            </plugin>           
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>AT*</exclude>
                        <exclude>IT*</exclude>
                        <exclude>BlueCostSpreadsheetUploadTestSuite</exclude>
                    </excludes>
                    <skipTests>${skip.surefire.tests}</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                     <execution>
                        <id>integration-tests</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <excludes>
                                <exclude>TestApplicationProperties</exclude>
                                <exclude>UTSampleTests</exclude>
                                <exclude>FT*</exclude>
                                <exclude>UT*</exclude>
                            </excludes>
                            <!-- Sets the VM argument line used when integration tests are run. -->
                            <argLine>${failsafeArgLine}</argLine>
                            <!--
                                Skips integration tests if the value of skip.integration.tests property
                                is true
                            -->
                            <skipTests>${skip.failsafe.tests}</skipTests>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!--
                Unit Test Jacoco Reports
            -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.1</version>
                <executions>
                    <!--
                        Prepares the property pointing to the JaCoCo runtime agent which
                        is passed as VM argument when Maven the Surefire plugin is executed.
                    -->
                    <execution>
                        <id>pre-unit-test</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                        <configuration>
                            <skipTests>${skip.surefire.tests}</skipTests>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                        </configuration>
                    </execution>
                    <!--
                        Ensures that the code coverage report for unit tests is created after
                        unit tests have been run.
                    -->
                    <execution>
                        <id>post-unit-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <skipTests>${skip.surefire.tests}</skipTests>
                            <!-- Sets the path to the file which contains the execution data. -->
                            <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                            <!-- Sets the output directory for the code coverage report. -->
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>           
        </plugins>
    </build>
</project>

Теперь, когда я запускаю mvn test на существующих тестовых примерах, я получаю следующую ошибку:

[INFO] Running com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests
Aug 06, 2018 5:19:12 PM org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTestContextBootstrapper buildDefaultMergedContextConfiguration
INFO: Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests], using SpringBootContextLoader
Aug 06, 2018 5:19:12 PM org.springframework.test.context.support.AbstractContextLoader generateDefaultLocations
INFO: Could not detect default resource locations for test class [com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests]: no resource found for suffixes {-context.xml, Context.groovy}.
Aug 06, 2018 5:19:12 PM org.springframework.test.context.support.AnnotationConfigContextLoaderUtils detectDefaultConfigurationClasses
INFO: Could not detect default configuration classes for test class [com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests]: UTBlueCostRestControllerTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.083 s <<< FAILURE! - in com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests
[ERROR] initializationError(com.ibm.cio.cloud.cost.spreadsheet.controller.UTBlueCostRestControllerTests)  Time elapsed: 0.015 s  <<< ERROR!
java.lang.NoSuchMethodError: org.springframework.util.Assert.state(ZLjava/util/function/Supplier;)V

Я нашел несколько потоков по этой теме, которые указывают на то, что существует проблема с путем к классам - скорее всего, Spring-core находится в пути к классам дважды, но я не могу найти проблему. Я распечатал дерево зависимостей, используя плагин зависимостей mvn для помощи в устранении неполадок, но я не вижу ничего явно неправильного. Пожалуйста помоги:

[INFO] Verbose not supported since maven-dependency-plugin 3.0
[WARNING] The artifact org.codehaus.mojo:sonar-maven-plugin:pom:3.4.0.905 has been relocated to org.sonarsource.scanner.maven:sonar-maven-plugin:pom:3.4.0.905
[INFO] SpreadSheetUploadWeb:SpreadSheetUploadWeb:jar:1.0
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.0.4.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:2.0.4.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-context:jar:4.3.9.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.4.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.4.RELEASE:compile
[INFO] |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
[INFO] |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
[INFO] |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] |  +- org.springframework:spring-core:jar:4.3.9.RELEASE:compile
[INFO] |  |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  \- org.yaml:snakeyaml:jar:1.19:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.4.RELEASE:compile
[INFO] |  +- com.zaxxer:HikariCP:jar:2.7.9:compile
[INFO] |  \- org.springframework:spring-jdbc:jar:4.3.9.RELEASE:compile
[INFO] |     +- org.springframework:spring-beans:jar:4.3.9.RELEASE:compile
[INFO] |     \- org.springframework:spring-tx:jar:4.3.9.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.0.4.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.4.RELEASE:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.6:compile
[INFO] |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.6:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.6:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.6:compile
[INFO] |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.6:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.4.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.6:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.6:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.6:compile
[INFO] |  +- org.hibernate.validator:hibernate-validator:jar:6.0.11.Final:compile
[INFO] |  |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  |  \- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  +- org.springframework:spring-web:jar:4.3.9.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-aop:jar:4.3.9.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:4.3.9.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:4.3.9.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.0.4.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.0.4.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.0.4.RELEASE:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.3:test
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.2:test
[INFO] |  |        \- org.ow2.asm:asm:jar:5.0.4:test
[INFO] |  +- junit:junit:jar:4.12:test
[INFO] |  +- org.assertj:assertj-core:jar:3.9.1:test
[INFO] |  +- org.mockito:mockito-core:jar:2.15.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.7.11:compile
[INFO] |  |  +- net.bytebuddy:byte-buddy-agent:jar:1.7.11:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.6:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-test:jar:4.3.9.RELEASE:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.5.1:test
[INFO] +- org.apache.poi:poi-ooxml:jar:3.15:compile
[INFO] |  \- com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] +- org.apache.poi:poi:jar:3.15:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.11:compile
[INFO] |  \- org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] +- org.apache.poi:poi-ooxml-schemas:jar:3.15:compile
[INFO] |  \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] |     \- stax:stax-api:jar:1.0.1:compile
[INFO] +- com.ibm.db2.jcc:db2jcc_license_cisuz:jar:10.5.9:compile
[INFO] +- com.ibm.db2.jcc:db2jcc4:jar:10.5.9:compile
[INFO] +- org.hsqldb:hsqldb:jar:2.4.0:test
[INFO] +- org.sonarsource.scanner.maven:sonar-maven-plugin:pom:3.4.0.905:compile
[INFO] |  +- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.4:compile
[INFO] |  |  \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] |  +- org.codehaus.plexus:plexus-utils:jar:3.0.22:compile
[INFO] |  +- org.sonarsource.scanner.api:sonar-scanner-api:jar:2.10.0.1189:compile
[INFO] |  \- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- org.flywaydb:flyway-core:jar:5.0.7:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.9.2:compile
[INFO] |  +- io.swagger:swagger-annotations:jar:1.5.20:compile
[INFO] |  +- io.swagger:swagger-models:jar:1.5.20:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |  +- io.springfox:springfox-spi:jar:2.9.2:compile
[INFO] |  |  \- io.springfox:springfox-core:jar:2.9.2:compile
[INFO] |  +- io.springfox:springfox-schema:jar:2.9.2:compile
[INFO] |  +- io.springfox:springfox-swagger-common:jar:2.9.2:compile
[INFO] |  +- io.springfox:springfox-spring-web:jar:2.9.2:compile
[INFO] |  +- com.google.guava:guava:jar:20.0:compile
[INFO] |  +- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] |  +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] |  \- org.mapstruct:mapstruct:jar:1.2.0.Final:compile
[INFO] \- io.springfox:springfox-swagger-ui:jar:2.9.2:compile

Я должен добавить, что после обновления версии я выполнил следующие команды на своем компьютере:

mvn clean mvn eclipse: чистый mvn eclipse: затмение

Обновление проекта в Eclipse. Я могу попробовать повторно импортировать данные в другое рабочее пространство, но на данный момент у меня нет идей, и мне нужна помощь.

Пользовательский скаляр GraphQL
Пользовательский скаляр GraphQL
Листовые узлы системы типов GraphQL называются скалярами. Достигнув скалярного типа, невозможно спуститься дальше по иерархии типов. Скалярный тип...
Поднятие тревоги для долго выполняющихся методов в Spring Boot
Поднятие тревоги для долго выполняющихся методов в Spring Boot
Приходилось ли вам сталкиваться с требованиями, в которых вас могли попросить поднять тревогу или выдать ошибку, когда метод Java занимает больше...
Версия Java на основе версии загрузки
Версия Java на основе версии загрузки
Если вы зайдете на официальный сайт Spring Boot , там представлен start.spring.io , который упрощает создание проектов Spring Boot, как показано ниже.
Документирование API с помощью Swagger на Springboot
Документирование API с помощью Swagger на Springboot
В предыдущей статье мы уже узнали, как создать Rest API с помощью Springboot и MySql .
0
0
4 249
2
Перейти к ответу Данный вопрос помечен как решенный

Ответы 2

Ответ принят как подходящий

Как упоминалось в https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Release-Notes#third-party-library-upgrades и https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide#dependency-versions, вам необходимо обновить версию Spring до 5.x.

В вашем pom.xml измените

<spring.version>4.3.9.RELEASE</spring.version>

к

<spring.version>5.0.8.RELEASE</spring.version>

Возможно, вам потребуется внести еще несколько изменений в эту миграцию основной весенней версии.

Огромное спасибо! Это сработало, как волшебный амулет из страны Оз!

JamesD 07.08.2018 15:32

Вместо добавления родителя в качестве Spring Boot используйте управление зависимостями с помощью Spring Boot Bill of Materials.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.0.2.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Таким образом, вам не нужно вручную добавлять номера версий для каждой зависимости.

Бывший:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
        </dependency>

<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>
<dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-core</artifactId>
        </dependency>

Здесь вы можете просмотреть сведения о зависимости и версии. http://central.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.0.2.RELEASE/spring-boot-dependencies-2.0.2.RELEASE.pom

Если вы посмотрите на - ссылка на сайт в теге свойств, вы увидите все указанные версии. Таким образом, вам не нужно указывать версии, нужно будет проверить тег свойства и применить версию. Если вы хотите переопределить существующую зависимость, вы можете переопределить ее своей версией. Таким образом, вам больше не придется беспокоиться о несовпадении версий.

Kaiizok 09.08.2018 08:35

Другие вопросы по теме