[JAVA] What I fixed when updating to Spring Boot 1.5.12 ・ What I was addicted to

Introduction

The project I was originally creating was Spring Boot 1.3.3, Since there was a Spring Framework vulnerability in April, We have decided to upgrade to Spring Boot 1.5.12 corresponding to it.

Of course, simply rewriting the version with pom.xml was not enough, so ... The problems that occurred at that time and how to solve them are listed below.

Test code compilation error

I used the following two annotations in the test code, With the version upgrade, I got angry that I couldn't find it.

@SpringApplicationConfiguration(classes=MyConfig.class)
@WebIntegrationTest

After investigating, it is said that both will use `` `@ SpringBootTest``` instead on the following page. https://stackoverflow.com/questions/42395225/springapplicationconfiguration-not-found-erroneous-spring-boot-starter-test-con

From @SpringApplicationConfiguration(classes=MyConfig.class) to @SpringBootTest(classes=MyConfig.class) From @WebIntegrationTest to @SpringBootTest(webEnvironment=WebEnvironment.DEFINED_PORT) (or RANDOM_PORT)

I used both this time, so I rewrote it as follows.

@SpringBootTest(classes=MyConfig.class, webEnvironment=WebEnvironment.RANDOM_PORT)



 With the above, the error of the test code has been resolved.

# Interface not found error
 I was importing the ```EmbeddedServletContainerCustomizer``` interface to display the error screen.
 When I build after upgrading, I get angry that I can't find it.
 really? I searched for an alternative like the above test code, but I couldn't find it ...

 Is it really not there? I thought, and when I searched the hierarchy under ``` spring-boot-1.5.12.RELEASE.jar```,
```embeddedservletcontainercustomizer```The interface file itself existed.

When I try to see the contents on it, the following error occurs and I cannot see the contents.```
java.util.zip.ZipException: invalid LOC header (bad signature)

When I looked it up, it seems that the cause is that the version of the jar file is wrong. As a workaround, delete the following maven repository folder and restart STS.

C: \ Users \ [username] \ .m2 \ repository

This completes the handling of the interface not found error.

Error when running the project

Apart from the above two correspondences When I thought about running the project after the version upgrade, The following desperate error occurs.

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
    at jp.co.ysk.pepper.qlip.App.main(App.java:12)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 1 more

I did some research, but I don't know the root cause. For the time being, this error was also resolved by eliminating the two compilation errors.

I feel a little uneasy, but ... That's it.

Recommended Posts

What I fixed when updating to Spring Boot 1.5.12 ・ What I was addicted to
What I was addicted to when developing a Spring Boot application with VS Code
What I was addicted to when introducing the JNI library
A memo that I was addicted to when making batch processing with Spring Boot
What I was addicted to when implementing google authentication with rails
What I was addicted to when updating the PHP version of the development environment (Docker) from 7.2.11 to 7.4.x
I was addicted to starting sbt
What I was addicted to while using rspec on rails
A site that was easy to understand when I was a beginner when I started learning Spring Boot
What I was addicted to with the Redmine REST API
What I was addicted to when trying to properly openAPI/Swagger documentation with Rails + Grape + Grape Swagger
The story I was addicted to when setting up STS
[MacOS] I was disturbed by ruby when installing Spring Boot CLI
A note when I was addicted to converting Ubuntu on WSL1 to WSL2
What I did in the migration from Spring Boot 1.4 series to 2.0 series
What I did in the migration from Spring Boot 1.5 series to 2.0 series
I was addicted to rewriting to @SpringApplicationConfiguration-> @SpringBootTest
Story when moving from Spring Boot 1.5 to 2.1
I was addicted to the roll method
Changes when migrating from Spring Boot 1.5 to Spring Boot 2.0
Changes when migrating from Spring Boot 2.0 to Spring Boot 2.2
I was addicted to the Spring-Batch test
[Rails] I was addicted to the nginx settings when using Action Cable.
A story I was addicted to when testing the API using MockMVC
My.cnf configuration problem that I was addicted to when I was touching MySQL 8.0 like 5.7
Problems I was addicted to when building the digdag environment with docker
Summary of what I learned about Spring Boot
I was addicted to installing Ruby/Tk on MacOS
I was addicted to doing onActivityResult () with DialogFragment
What I did when I converted java to Kotlin
I wanted to gradle spring boot with multi-project
When internationalizing is supported by Spring Boot, a specific locale is not translated and I am addicted to it
I was addicted to the NoSuchMethodError in Cloud Endpoints
I was addicted to the record of the associated model
05. I tried to stub the source of Spring Boot
I tried to reduce the capacity of Spring Boot
A story I was addicted to when getting a key that was automatically tried on MyBatis
Try Spring Boot from 0 to 100.
I knew what reflection was
I was addicted to setting default_url_options with Rails devise introduction
I was addicted to looping the Update statement on MyBatis
Introduction to Spring Boot ① ~ DI ~
Introduction to Spring Boot ② ~ AOP ~
A story I was addicted to in Rails validation settings
I was addicted to the setting of laradock + VSCode + xdebug
Introduction to Spring Boot Part 1
I was addicted to using Java's Stream API in Scala
I tried to get started with Swagger using Spring Boot
I was addicted to WSl when trying to build an android application development environment with Vue.js
[Rails] How to solve ActiveSupport :: MessageVerifier :: InvalidSignature that I was addicted to when introducing twitter login [ActiveStorage]
I want to know the Method of the Controller where the Exception was thrown in the ExceptionHandler of Spring Boot
[Circle CI] A story I was addicted to at Start Building
02. I made an API to connect to MySQL (MyBatis) from Spring Boot
About the matter that I was addicted to how to use hashmap
I want to control the default error message of Spring Boot
I was addicted to the API version min23 setting of registerTorchCallback
What I thought about when I started migrating from Java to Kotlin
Memorandum of understanding when Spring Boot 1.5.10 → Spring Boot 2.0.0
I went to JJUG CCC 2019 Spring
How to set Spring Boot + PostgreSQL
What is @Autowired in Spring boot?