Skip to content

Commit

Permalink
SHIRO-704 - Update Spring, Spring Boot + Hibernate
Browse files Browse the repository at this point in the history
  • Loading branch information
coheigea committed Jun 14, 2019
1 parent a73cf77 commit 8767b7d
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 20 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@
<slf4j.version>1.7.26</slf4j.version>
<logback.version>1.2.3</logback.version>
<log4j.version>1.2.17</log4j.version>
<spring.version>4.3.24.RELEASE</spring.version>
<spring-boot.version>1.5.21.RELEASE</spring-boot.version>
<spring.version>5.1.7.RELEASE</spring.version>
<spring-boot.version>2.1.5.RELEASE</spring-boot.version>
<guice.version>3.0</guice.version>
<jaxrs.api.version>2.0.1</jaxrs.api.version>
<htmlunit.version>2.35.0</htmlunit.version>
Expand All @@ -113,7 +113,7 @@
<groovy.version>2.4.7</groovy.version>
<junit.version>4.12</junit.version>
<junit.server.jetty.version>0.11.0</junit.server.jetty.version>
<hibernate.version>4.2.21.Final</hibernate.version>
<hibernate.version>5.4.3.Final</hibernate.version>
<taglib.standard.version>1.1.2</taglib.standard.version>
<!-- so we can mock static methods in 3rd party libraries that sometimes don't use proper interfaces
ahem, hazelcast, ahem... -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
package org.apache.shiro.samples;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ErrorAttributes;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.ServletWebRequest;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
Expand All @@ -45,7 +45,7 @@ public String getErrorPath() {

@RequestMapping(ERROR_PATH)
String error(HttpServletRequest request, Model model) {
Map<String, Object> errorMap = errorAttributes.getErrorAttributes(new ServletRequestAttributes(request), false);
Map<String, Object> errorMap = errorAttributes.getErrorAttributes(new ServletWebRequest(request), false);
model.addAttribute("errors", errorMap);
return "error";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class User {


@Id
@GeneratedValue
@GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() {
return id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</bean>

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- Scan packages for JPA annotations -->
<property name="packagesToScan" value="org.apache.shiro.samples.sprhib.model"/>
Expand All @@ -70,7 +70,7 @@
</bean>

<!-- Transaction support beans -->
<bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@

<!-- Enable annotation-based controllers using @Controller annotations -->
<bean id="annotationUrlMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
<property name="interceptors" ref="currentUserInterceptor"/>
</bean>

<bean id="annotationMethodHandlerAdapter"
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>

<!-- All views are JSPs loaded from /WEB-INF/jsp -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
Expand All @@ -52,4 +52,4 @@
<property name="suffix" value=".jsp"/>
</bean>

</beans>
</beans>
5 changes: 1 addition & 4 deletions samples/spring-hibernate/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
<!-- ===================================================================
- Servlet listeners
- =================================================================== -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Expand All @@ -56,7 +53,7 @@
- =================================================================== -->
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
</filter>

<!-- Shiro Filter is defined in the spring application context: -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.DelegatingFilterProxy;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.util.Log4jConfigListener;

import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
Expand All @@ -45,8 +44,6 @@ public void onStartup(ServletContext container) {
// Manage the lifecycle of the root application context
container.addListener(new ContextLoaderListener(appContext));

container.addListener(new Log4jConfigListener());

FilterRegistration.Dynamic shiroFilter = container.addFilter("shiroFilterFactoryBean", DelegatingFilterProxy.class);
shiroFilter.setInitParameter("targetFilterLifecycle", "true");
shiroFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
Expand Down

0 comments on commit 8767b7d

Please sign in to comment.