Merge pull request #9290 from sampada07/JAVA-913
JAVA-913: migrate parent-boot-1 articles to parent-boot-2
This commit is contained in:
commit
1e3a588cb1
|
@ -10,9 +10,9 @@
|
|||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
<relativePath>../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -23,11 +23,24 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.mobile</groupId>
|
||||
<artifactId>spring-mobile-device</artifactId>
|
||||
<version>${spring-mobile-device.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/libs-milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<spring-mobile-device.version>2.0.0.M3</spring-mobile-device.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.baeldung;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.mobile.device.DeviceHandlerMethodArgumentResolver;
|
||||
import org.springframework.mobile.device.DeviceResolverHandlerInterceptor;
|
||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class AppConfig implements WebMvcConfigurer {
|
||||
|
||||
@Bean
|
||||
public DeviceResolverHandlerInterceptor deviceResolverHandlerInterceptor() {
|
||||
return new DeviceResolverHandlerInterceptor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DeviceHandlerMethodArgumentResolver deviceHandlerMethodArgumentResolver() {
|
||||
return new DeviceHandlerMethodArgumentResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(deviceResolverHandlerInterceptor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||
argumentResolvers.add(deviceHandlerMethodArgumentResolver());
|
||||
}
|
||||
|
||||
}
|
|
@ -16,13 +16,16 @@ public class IndexController {
|
|||
|
||||
String deviceType = "browser";
|
||||
String platform = "browser";
|
||||
String viewName = "index";
|
||||
|
||||
if (device.isNormal()) {
|
||||
deviceType = "browser";
|
||||
} else if (device.isMobile()) {
|
||||
deviceType = "mobile";
|
||||
viewName = "mobile/index";
|
||||
} else if (device.isTablet()) {
|
||||
deviceType = "tablet";
|
||||
viewName = "tablet/index";
|
||||
}
|
||||
|
||||
platform = device.getDevicePlatform().name();
|
||||
|
@ -33,7 +36,7 @@ public class IndexController {
|
|||
|
||||
LOGGER.info("Client Device Type: " + deviceType + ", Platform: " + platform);
|
||||
|
||||
return "index";
|
||||
return viewName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
spring.mobile.devicedelegatingviewresolver.enabled: true
|
||||
spring.mobile.devicedelegatingviewresolver.enabled: true
|
||||
spring.freemarker.template-loader-path: classpath:/templates
|
||||
spring.freemarker.suffix: .ftl
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
<relativePath>../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -19,25 +19,26 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-rest-hal-browser -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-rest-hal-browser</artifactId>
|
||||
<version>${spring-data.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${h2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy-dep</artifactId>
|
||||
<version>${bytebuddy.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -55,9 +56,7 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<spring-boot.version>2.0.3.RELEASE</spring-boot.version>
|
||||
<spring-data.version>3.0.8.RELEASE</spring-data.version>
|
||||
<h2.version>1.4.197</h2.version>
|
||||
<bytebuddy.version>1.10.10</bytebuddy.version>
|
||||
<source.version>1.8</source.version>
|
||||
<target.version>1.8</target.version>
|
||||
</properties>
|
||||
|
|
Loading…
Reference in New Issue