简体   繁体   中英

Spring MVC + Hibernate : 2 Tier Application with Spring Annotation

I want to create 2 tier application (Spring MVC) + (Spring Hibernate). This is what i want web layer: Java EE, Spring data access layer: Hibernate, Oracle database

As i am working in Spring MVC latest version, I want to use annotation like @Component/@Autowired/@Bean and Spring configuration, etc in DAL Layer.

But unable to do that. I am not finding any examples in such kind of scenario in web.

In Microsoft we can do that by Presentation Layer : ASP.NET DAL Layer : Entity Framework

but in JavaEE, I am unable to find how to do that.

For Jboss/Wildfly i am using beanRefContext.xml configuration in resources

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

    <!-- The injecting into EJB a spring container context -->
    <bean class="org.springframework.context.support.ClassPathXmlApplicationContext">
        <constructor-arg value="classpath*:spring-configuration.xml">
        </constructor-arg>
    </bean>
</beans>

All spring configururation in "spring-configuration.xml"

To injecting spring you need on EJB Controller class setup - @Interceptors(SpringBeanAutowiringInterceptor.class) And you can use Spring @Autowired and other.

Reading this aswer and docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM