Spring boot interaction with Spring MVC + Spring Security + Hibernate + HSQLDB -


i have finished work on spring-based(spring-mvc) web application uses spring security, hibernate, hsqldb (and maven of course). running web app on jetyy 9.x server integrated in intellij idea, need packaged in single executable jar embedded jetty server.

people offered me use spring boot embedding jetty purpose. found out (because tried , read info) spring boot not understand xml configuration files app using configuring spring-mvc , spring security.

how can make spring components interract each other , sould considering current (non spring boot project structure)?

the project structure , settings (non spring boot):

foder structure

jetty configs

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

code of configuration files:

hibernate.cfg.xml

<!doctype hibernate-configuration public         "-//hibernate/hibernate configuration dtd 3.0//en"         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">  <hibernate-configuration>     <session-factory>         <!-- database connection settings -->         <property name="connection.driver_class">org.hsqldb.jdbcdriver</property>         <property name="connection.url">jdbc:hsqldb:file:${webroot}/web-inf/classes/dbstorage/testdb</property>         <property name="connection.username">sa</property>         <property name="connection.password"></property>          <!-- jdbc connection pool (use built-in) -->         <property name="connection.pool_size">5</property>          <!-- sql dialect -->         <property name="dialect">org.hibernate.dialect.hsqldialect</property>          <!-- echo executed sql stdout -->         <property name="show_sql">true</property>         <!-- drop , re-create database schema on startup         <property name="hbm2ddl.auto">create</property>-->           <!-- mapping files -->         <mapping resource="user.hbm.xml"/>         <mapping resource="disk.hbm.xml"/>         <mapping resource="takenitem.hbm.xml"/>      </session-factory> </hibernate-configuration> 

applicationcontext.xml

<?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.xsd">  </beans> 

dispatcher-servlet.xml

<?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: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/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">      <!-- dispatcherservlet context: defines servlet's request-processing          infrastructure -->      <!-- enables spring mvc @controller programming model -->     <mvc:annotation-driven />      <!-- handles http requests /resources/** efficiently serving         static resources in ${webapproot}/resources directory -->     <mvc:resources mapping="/resources/**" location="/resources/" />      <context:component-scan base-package="com.dvdexchange" />      <!-- resolves views selected rendering @controllers .jsp resources         in /web-inf/views directory -->     <bean class="org.springframework.web.servlet.view.internalresourceviewresolver">         <property name="prefix" value="/web-inf/views/" />         <property name="suffix" value=".jsp" />     </bean> </beans> 

spring-database.xml

<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"        xsi:schemalocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/aop     http://www.springframework.org/schema/aop/spring-aop-3.0.xsd     http://www.springframework.org/schema/tx     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">      <!-- hsqldb data source -->     <bean id="datasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close">         <property name="driverclassname" value="org.hsqldb.jdbcdriver" />         <property name="url" value="jdbc:hsqldb:file:${webroot}/web-inf/classes/dbstorage/testdb" />         <property name="username" value="sa" />         <property name="password" value="" />     </bean>      <!-- hibernate session factory -->     <bean id="sessionfactory"           class="org.springframework.orm.hibernate5.localsessionfactorybean">         <property name="datasource" ref="datasource" />         <property name="mappingresources">             <list>                 <value>user.hbm.xml</value>                 <value>disk.hbm.xml</value>                 <value>takenitem.hbm.xml</value>             </list>         </property>         <property name="hibernateproperties">             <props>                 <prop key="hibernate.dialect">                     org.hibernate.dialect.mysql5dialect                 </prop>                 <prop key="hibernate.format_sql">true</prop>                 <prop key="hibernate.show_sql">true</prop>             </props>         </property>     </bean>      <bean id="userdao" class="com.dvdexchange.dao.impl.userdaohibernateimpl"/>      <bean id="myuserserviceimpl" class="com.dvdexchange.service.impl.userserviceimpl">         <property name="userdao" ref="userdao" />     </bean>      <!-- must have transaction manager, using aop , aspects  -->     <bean id="transactionmanager" class="org.springframework.orm.hibernate5.hibernatetransactionmanager">         <property name="sessionfactory" ref="sessionfactory"></property>     </bean>      <tx:advice id="txadvice" transaction-manager="transactionmanager">         <tx:attributes>             <tx:method name="get*" read-only="true" />             <tx:method name="find*" read-only="true" />             <tx:method name="*" />         </tx:attributes>     </tx:advice>      <aop:config>         <aop:pointcut id="userservicepointcut"                       expression="execution(* com.dvdexchange.service.*serviceimpl.*(..))" />         <aop:advisor advice-ref="txadvice" pointcut-ref="userservicepointcut" />     </aop:config>  </beans> 

spring-security.xml

<beans:beans xmlns="http://www.springframework.org/schema/security"              xmlns:beans="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     http://www.springframework.org/schema/security     http://www.springframework.org/schema/security/spring-security-3.2.xsd">      <!-- enable use-expressions -->     <http auto-config="true" use-expressions="true">         <intercept-url pattern="/disklib**" access="hasrole('role_user')"/>         <intercept-url pattern="/borrowdisk**" access="hasrole('role_user')"/>         <intercept-url pattern="/takendisks**" access="hasrole('role_user')"/>         <intercept-url pattern="/givendisks**" access="hasrole('role_user')"/>          <!-- access denied page -->         <access-denied-handler error-page="/403"/>          <form-login                 login-page="/login"                 default-target-url="/disklib"                 authentication-failure-url="/login?error"                 username-parameter="username"                 password-parameter="password"/>         <logout logout-success-url="/login?logout"/>         <!-- enable csrf protection -->         <csrf/>     </http>      <authentication-manager>         <authentication-provider user-service-ref="myuserserviceimpl">             <password-encoder hash="md5"/>         </authentication-provider>     </authentication-manager>  </beans:beans 


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -