Nieaktualne wpisy w application.properties
Nieaktualne wpisy w application.properties
Różnice w wersjach Spring Boota powodują to, że niektóre wpisy w pliku konfiguracyjnym application.properties są nieaktualne i nie mają zastosowania w aplikacji np.:
Przed wersją Spring Boota 2.0.0 ścieżka kontekstu aplikacji ustawiana była w następujący sposób:
server.contextPath
Od wersji Spring Boot 2.0.0 parametr ten został zmieniony i należy go ustawiać w następujący sposób:
server.servlet.contextPath
Aby temu zaradzić wydano oficjalne rozwiązanie:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-properties-migrator</artifactId> </dependency>
Tworzymy nowy projekt Spring Boota używając wersji wyższej niż 2 np. 2.1.6.RELEASE – niezbędne zależności – plik pom.xml:
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-properties-migrator</artifactId> </dependency> </dependencies>
Plik application.properties:
server.contextPath = /app
Wynik działania aplikacji to:
The use of configuration keys that have been renamed was found in the environment: Property source 'applicationConfig: [classpath:/application.properties]': Key: server.context-path Line: 1 Replacement: server.servlet.context-path Each configuration key has been temporarily mapped to its replacement for your convenience. To silence this warning, please update your configuration to use the new keys.
Podczas działania aplikacji nieaktualne wpisy są podmieniane.
Leave a comment