Skip to content

Commit

Permalink
Merge pull request mecdcme#12 from mecdcme/master
Browse files Browse the repository at this point in the history
Upgrade to SpringBoot2
  • Loading branch information
trygu authored May 24, 2019
2 parents 02ebb7f + 2e8f533 commit 84bb9fc
Show file tree
Hide file tree
Showing 54 changed files with 2,336 additions and 2,573 deletions.
51 changes: 27 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
<?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"
<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>

<groupId>it.istat.rservice</groupId>
<artifactId>rService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>${packaging.type}</packaging>
<name>IS2</name>
<description>Istat Statistical Service</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.2.RELEASE</version>
<relativePath />
<version>2.1.5.RELEASE</version>
<relativePath>..</relativePath> <!-- lookup parent from repository -->
</parent>

<groupId>it.istat.rservice</groupId>
<artifactId>rService</artifactId>
<version>0.9</version>
<packaging>${packaging.type}</packaging>
<name>IS2</name>
<description>Statistical Service Workbench</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Expand All @@ -40,7 +37,7 @@
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
<artifactId>thymeleaf-extras-springsecurity5</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -50,6 +47,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -73,12 +76,11 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>1.2.8.RELEASE</version>
</dependency>
<version>1.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<dependency>
<groupId>org.rosuda.REngine</groupId>
Expand All @@ -105,9 +107,10 @@
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
</dependencies>

<build>
Expand All @@ -122,12 +125,12 @@
<version>2.3.2</version>
<configuration>
<debug>false</debug>
<showDeprecation>true</showDeprecation>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
<finalName>is2</finalName>
<resources>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
Expand Down
141 changes: 77 additions & 64 deletions src/main/java/it/istat/rservice/AppConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* @author Stefano Macone <macone @ istat.it>
* @version 1.0
*/

package it.istat.rservice;

import java.util.Locale;
Expand All @@ -32,72 +31,86 @@
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver;
import org.thymeleaf.templateresolver.TemplateResolver;

@Configuration
public class AppConfiguration extends WebMvcConfigurerAdapter {

@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
lci.setParamName("language");
return lci;
}

@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
slr.setDefaultLocale(new Locale("it", "IT"));
return slr;
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}

@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("i18n/messages");
return messageSource;
}

@Bean(name = "multipartResolver")
public MultipartResolver multipartResolver() {
return new StandardServletMultipartResolver();
}

@Bean
public SpringTemplateEngine temp() {

SpringTemplateEngine st = new SpringTemplateEngine();
st.setTemplateResolver(templateResolver());
st.addTemplateModeHandler(SkipSpaceLineTemplateModeHandlers.getITemplateModeHandlerHTML5());
st.addDialect(securityDialect());
return st;
}

@Bean
public SpringSecurityDialect securityDialect() {
return new SpringSecurityDialect();
}

@Bean
public TemplateResolver templateResolver() {
TemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver.setPrefix("templates/");
templateResolver.setCacheable(false);
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("HTML5");

return templateResolver;
}
}
public class AppConfiguration implements WebMvcConfigurer {

@Bean
public LocaleChangeInterceptor localeChangeInterceptor() {
LocaleChangeInterceptor lci = new LocaleChangeInterceptor();
lci.setParamName("language");
return lci;
}

@Bean
public LocaleResolver localeResolver() {
SessionLocaleResolver slr = new SessionLocaleResolver();
slr.setDefaultLocale(new Locale("it", "IT"));
return slr;
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(localeChangeInterceptor());
}

@Bean
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("i18n/messages");
return messageSource;
}

@Bean(name = "multipartResolver")
public MultipartResolver multipartResolver() {
return new StandardServletMultipartResolver();
}

@Bean
public SpringSecurityDialect securityDialect() {
return new SpringSecurityDialect();
}

@Bean
public ClassLoaderTemplateResolver templateResolver() {

ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();

templateResolver.setPrefix("templates/");
templateResolver.setCacheable(false);
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("HTML5");
templateResolver.setCharacterEncoding("UTF-8");

return templateResolver;
}

@Bean
public SpringTemplateEngine templateEngine() {

SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.setTemplateResolver(templateResolver());
templateEngine.addDialect(securityDialect());
return templateEngine;
}

@Bean
public ViewResolver viewResolver() {

ThymeleafViewResolver viewResolver = new ThymeleafViewResolver();

viewResolver.setTemplateEngine(templateEngine());
viewResolver.setCharacterEncoding("UTF-8");

return viewResolver;
}
}
22 changes: 9 additions & 13 deletions src/main/java/it/istat/rservice/RServiceApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,25 @@
* @author Stefano Macone <macone @ istat.it>
* @version 1.0
*/

package it.istat.rservice;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.PropertySource;

@PropertySource(value = { "classpath:application.properties" })
@SpringBootApplication

@PropertySource(value = {"classpath:application.properties"})
public class RServiceApplication extends SpringBootServletInitializer {

public static void main(String[] args) {

SpringApplication.run(RServiceApplication.class, args);
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
public static void main(String[] args) {
SpringApplication.run(RServiceApplication.class, args);
}

return application.sources(RServiceApplication.class);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RServiceApplication.class);
}
}
Loading

0 comments on commit 84bb9fc

Please sign in to comment.