integrating tiles in spring3, getting java.lang.NoSuchFieldError: PATCH exception - spring-mvc

Let me know how to initialize tiles from dispatcher and application context and if any changes required in web.xml,
this is my tiles.xml
<definition name="contact" extends="mainLayout">
<put-attribute name="title" value="Contact Manager" />
<put-attribute name="body" value="/WEB-INF/jsp/contact.jsp" />
</definition>
</tiles-definitions>
in application context i have used
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="requestContextAttribute" value="requestContext"/>
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
and dispatcher looks like this
<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
indexController</prop>-->
newController
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer" id="tilesConfigurer">
<property name="definitions">
<list>
<value>WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="viewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles2.TilesView
</value>
</property>

In Dispatcher-Servlet
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
In web.xml use this code
<listener>
<listener-class>org.apache.tiles.web.startup.simple.SimpleTilesListener</listener-class>
</listener>
rest is not required for spring-tiles application, tiles.xml is depended on your requirement

Related

How to enable #RequiresPermissions in Spring MVC project?

Having spent days trying to get my head around AOP, I have no option than to lay out my code and hope the good guys on the internet will help me.
My dispatcher-servlet.xml:
<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?xml version=".0" encoding="UTF-8"?> -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.company.project"/>
<mvc:annotation-driven/>
<mvc:resources mapping="/resources/**" location="/WEB-INF/resources/, file:${catalina.home}/project/resources/" />
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="index.htm">indexController</prop>
</props>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp" />
<!--
The index controller.
-->
<bean name="indexController"
class="org.springframework.web.servlet.mvc.ParameterizableViewController"
p:viewName="index" />
</beans>
applicationContext.xml:
<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?xml version="1.0" encoding="UTF-8"?> -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<aop:aspectj-autoproxy proxy-target-class="true"/>
<context:component-scan base-package="com.company.project"/>
<!-- Transaction Management -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>/WEB-INF/jdbc.properties</value>
<value>/WEB-INF/c3p0.properties</value>
<value>/WEB-INF/application.properties</value>
</list>
</property>
</bean>
<!-- With c3p0-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="packagesToScan" value="com.company.project.model"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<!-- <prop key="hibernate.current_session_context_class">thread</prop>-->
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.id.new_generator_mappings">false</prop>
<prop key="net.sf.ehcache.configurationResourceName">ehcache.xml</prop>
<prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
<prop key="hibernate.connection.driver_class">${jdbc.driverClassName}</prop>
<prop key="hibernate.connection.url">${jdbc.url}</prop>
<prop key="hibernate.connection.username">${jdbc.username}</prop>
<prop key="hibernate.connection.password">${jdbc.password}</prop>
<!-- <prop key="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</prop>-->
<prop key="hibernate.c3p0.acquire_increment">1</prop>
<prop key="hibernate.c3p0.idle_test_period">300</prop>
<prop key="hibernate.c3p0.max_size">20</prop>
<prop key="hibernate.c3p0.max_statements">100</prop>
<prop key="hibernate.c3p0.min_size">3</prop>
<prop key="hibernate.c3p0.preferredTestQuery">SELECT 1;</prop>
<prop key="hibernate.c3p0.testConnectionOnCheckin">true</prop>
</props>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="shiroFilter" class= "org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager"/>
<property name="loginUrl" value="/verify.jsp"/>
<property name="successUrl" value="/index"/>
<property name="filterChainDefinitions">
<value>
/verify.jsp = authc
/secure/** = authc
/logout.htm = logout
/api/test/** = anon
/api/** = jwtv
</value>
</property>
</bean>
<bean id="logout" class="org.apache.shiro.web.filter.authc.LogoutFilter">
<property name="redirectUrl" value="/login.jsp"/>
</bean>
<bean id="annon" class="org.apache.shiro.web.filter.authc.AnonymousFilter">
</bean>
<bean id="jwtg" class="com.company.project.model.api.ApiGuard">
</bean>
<bean id="jwtv" class="com.company.project.model.api.JWTVerifyingFilter">
</bean>
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<!-- Single realm app. If you have multiple realms, use the 'realms' property instead. -->
<property name="realm" ref="jdbcRealm"/>
<property name="cacheManager" ref="cacheManager"/>
<!-- By default the servlet container sessions will be used. Uncomment this line
to use shiro's native sessions (see the JavaDoc for more): -->
<!-- <property name="sessionMode" value="native"/> -->
</bean>
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
<!-- Enable Shiro Annotations for Spring-configured beans. Only run after
the lifecycleBeanProcessor has run: -->
<bean id="annotationProxy"
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
depends-on="lifecycleBeanPostProcessor" />
<bean
class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager" />
</bean>
<bean id="jdbcRealm" class="org.apache.shiro.realm.jdbc.JdbcRealm">
<property name="credentialsMatcher" ref = "sha256Matcher"/>
<property name="authenticationQuery" value = "SELECT password, salt FROM admin WHERE email = ?"/>
<property name="permissionsLookupEnabled" value = "true"/>
<property name="userRolesQuery" value = "SELECT role_name FROM admin_role WHERE email = ?"/>
<property name="permissionsQuery" value = "SELECT permission FROM roles_permission WHERE role_name = ?"/>
<property name="saltStyle" value = "COLUMN"/>
<property name="dataSource" ref = "dataSource"/>
</bean>
<bean id="sha256Matcher" class="org.apache.shiro.authc.credential.HashedCredentialsMatcher" >
<property name="hashAlgorithmName" value = "SHA-256"/>
</bean>
<bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="10000000"/>
</bean>
</beans>
If I comment out the part:
<bean id="annotationProxy"
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"
depends-on="lifecycleBeanPostProcessor" />
<bean
class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager" />
</bean>
the project runs but the #RequiresPermissions annotation is useless. When I run the project with these config Error is:
[http-nio-8084-exec-100] WARN
org.springframework.web.context.support.XmlWebApplicationContext -
Exception encountered during context initialization - cancelling
refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'myController': Unsatisfied
dependency expressed through field 'myService'; nested exception
is org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'myService' is expected to be of type
[com.company.project.service.myService] but was actually of type
[com.sun.proxy.$Proxy530] [http-nio-8084-exec-100] ERROR
org.springframework.web.context.ContextLoader - Context initialization
failed
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'myController': Unsatisfied
dependency expressed through field 'myService'; nested exception
is org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'myService' is expected to be of type
[com.company.project.service.myService] but was actually of type
[com.sun.proxy.$Proxy530] at
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)
My controller classes are smth like:
#RestController
#RequestMapping(value = "/api/my")
public class MyApis {
#Autowired
MyService myService;
#RequestMapping(method = RequestMethod.GET, value = "/profile/save")
#RequiresPermissions("profile:save")
public void saveProfile(#RequestParam(value = "first-name") String firstName, #RequestParam(value = "last-name") String lastName,HttpServletRequest request) {
Profile profile = new Profile();
profile.setFirstName(firstName);
profile.setLastName(lastName);
myService.insert(profile);
}
}
Please help me figure out setting up Shiro annotations. Thank you.
Shiro has a Spring Boot example that uses Shiro's annotations on a controller. And a non-boot example too

Whenever I am adding ContentNegotiatingViewResolver bean, All my other jsp pages stops working

Whenever I am adding ContentNegotiatingViewResolver bean, All my other jsp pages stops working, I get this error - HTTP Status 500 - Servlet.init() for servlet fitTrackerServlet threw exception
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.ContentNegotiatingViewResolver#0' defined in ServletContext resource [/WEB-INF/config/servlet-config.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonGenerator
This is my servlet-config.xml
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" p:order="0"/>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="order" value="1"/>
<property name="contentNegotiationManager">
<bean class="org.springframework.web.accept.ContentNegotiationManager">
<constructor-arg>
<bean class="org.springframework.web.accept.PathExtensionContentNegotiationStrategy">
<constructor-arg>
<map>
<entry key="json" value="application/json"/>
<entry key="xml" value="application/xml"/>
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg>
<bean class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="autodetectAnnotations" value="true"/>
</bean>
</constructor-arg>
</bean>
</list>
</property>
</bean>

setting up an sql connection to run a spring-mvc project, using intelliJ

I've cloned a spring-mvc project to my computer and trying to get it running using intelliJ. It seems, according to this that I need to establish an SQL connection. Do I need to download mysql to my computer, create an account and enter that information in my connection.XML file (seen below)?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Data Source Setup -->
<bean id="hsqldataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:hsql" />
<property name="username" value="example" />
<property name="password" value="example" />
</bean>
<bean id="mysqldataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://192.168.0.0.0:3306/dev" />
<property name="username" value="example" />
<property name="password" value="example" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>example/peer-review/domain/hibernatemapping/Division.hbm.xml</value>
<value>example/peer-review/domain/hibernatemapping/Modality.hbm.xml</value>
<value>example/peer-review/domain/hibernatemapping/Score.hbm.xml</value>
<value>example/peer-review/domain/hibernatemapping/User.hbm.xml</value>
<value>example/peer-review/domain/hibernatemapping/QaCase.hbm.xml</value>
<value>example/peer-review/domain/hibernatemapping/Review.hbm.xml</value>
<value>example/peer-review/domain/hibernatemapping/Exam.hbm.xml</value>
<value>example/peer-review/domain/hibernatemapping/Patient.hbm.xml</value>
<value>example/peer-review/domain/hibernatemapping/Role.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
<property name="dataSource" ref="hsqldataSource" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- Dao Layer generic config-->
<bean id="abstractDaoTarget" class="example.peer-review.persistence.hibernate.GenericDAOHibernateImpl" abstract="true">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Dao Layer instances -->
<bean id="DivisionDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.DivisionDAOHibernateImpl" />
<bean id="ModalityDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.ModalityDAOHibernateImpl" />
<bean id="ScoreDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.ScoreDAOHibernateImpl" />
<bean id="UserDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.UserDAOHibernateImpl" />
<bean id="ReviewDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.ReviewDAOHibernateImpl" />
<bean id="QaCaseDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.QaCaseDAOHibernateImpl" />
<bean id="ExamDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.ExamDAOHibernateImpl" />
<bean id="PatientDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.PatientDAOHibernateImpl" />
<bean id="RoleDAO" parent="abstractDaoTarget" class="example.peer-review.persistence.hibernate.RoleDAOHibernateImpl" />
<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource">
<property name="url" value="ldap://example.edu:1234" />
<property name="base" value="" />
<property name="userDn" value="cn=Test1" />
<property name="password" value="Test1" />
<property name="authenticationStrategy" ref="ldapAuthStrat" />
</bean>
<bean id="ldapTemplate" class="org.springframework.ldap.core.LdapTemplate">
<constructor-arg ref="contextSource" />
</bean>
<bean id="ldapAuthStrat" class="org.springframework.ldap.core.support.ExternalTlsDirContextAuthenticationStrategy" />
</beans>
Your conf file contains the definition for two different datasources, hsql and mysql. hsql is an in memory db.
Mysql is standalone database application.
yes to connect to the mysql source, you need to download mysql and set up users/schema.

i18n with Spring MVC, skip RequestMapping

I have set up i18n to my web app using Spring.It works fine.But I have a problem.When I click link to different language,from, lets say edit_user page. The request url is generated as '/edit_user.htm?lang=de'.Controller class receives this request and run editUser method based on #RequestMapping(value = { "edit_user" }). How to avoid this from happening.I just want my web app to be able to simply change the locale without reaching controller class methods when clicked on "change language links". My spring-config-servlet.xml is as following.
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:i18n/messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<ref bean="localeChangeInterceptor" />
</property>
</bean>
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate" />
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="order" value="1" />
<property name="mediaTypes">
<map>
<entry key="pretty" value="text/html" />
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
</map>
</property>
<property name="defaultViews">
<list>
<bean
class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg>
<bean class="org.springframework.oxm.xstream.XStreamMarshaller" />
</constructor-arg>
</bean>
</list>
</property>
<property name="ignoreAcceptHeader" value="true" />
</bean>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="2" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
....
</property>
<property name="defaultErrorView" value="errorPage" />
</bean>
Hm... Interesting.
UserController class receives this request:
en | de
for URL http://www.example.com/AppName/User/edit_user.htm?lang=de and run editUser method.
But you can change your links to:
EN | DE
and now when user click link to different language HomeController class receives request /?lang=de, web app change the locale and redirect user to the root page http://www.example.com/AppName/?lang=de.
Is this behavior acceptable for your application?
Otherwise I guess you have to filter request params for all controller classes if you want to find another solution.

Configuring multiple controllers in dispatcher servlet

I am new to spring-hibernate integration.
I am trying to enter data into database through jsp form, and I am getting a null pointer exception when the object is trying to persit.
I checked if the object is receiving values, and it does.
The reason I feel is because the dispatcher servelet is not allowing me to pass the value through.
Bellow is my dispatcher-servlet.
If any one can me show me the way to configure multiple controllers in dispatcher servelet it would be great.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<!-- maps request URLs to Controller names -->
<!-- <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/> -->
<!-- bean class="com.skopic.web.controller.UserController" /-->
<bean name="/index/*.htm" class="com.skopic.web.controller.IndexController" >
<!-- <property name="UserDAO" ref="myUserDAO" /> -->
</bean>
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:skopicportal.${SKAPP_ENV}.properties</value>
</list>
</property>
</bean>
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/testdb"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
<!-- <bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="annotatedClasses">
<list>
<value>com.skopic.web.controller.Tenant</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<bean id="myTenantDAO" class="com.skopic.web.controller.TenantDAOImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean> -->
<!-- User bean -->
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="annotatedClasses">
<list>
<value>com.skopic.web.controller.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<bean id="myUserDAO" class="com.skopic.web.controller.UserDAOImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>
<bean name="/user/*.htm" class="com.skopic.web.controller.UserController" >
<property name="UserDAO" ref="myUserDAO" />
</bean>
<!-- <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/> -->
<mvc:annotation-driven/>
<context:component-scan base-package="com.skopic.service"/>
<context:component-scan base-package="com.skopic.web.controller"/>
</beans>

Resources