采用spring+struts2+mybitas搭一个java web的框架(采用注解的形式) 200

采用spring+struts2+mybitas搭一个javaweb的框架,采用注解的形式(关键).层次分明(dao.domain.action.base.service... 采用spring+struts2+mybitas搭一个java web的框架,采用注解的形式(关键).
层次分明(dao.domain.action.base.service)
只要该有的配置文件都有(我不会配置),能跑起来helloworld就行了.最好能有个与数据库模拟交互的单元测试.
普通的java web 或者maven都行.
展开
 我来答
g511266804
2015-04-17
知道答主
回答量:26
采纳率:0%
帮助的人:18.9万
展开全部
给你看看 我的配置
<?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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">

<!-- spring启用注解 -->
<context:annotation-config />

<!-- spring中注解+自动扫描方式配置,@Repository:DAO层组件,@Service:业务层组件,@Controller:控制层组件 -->
<context:component-scan base-package="com.fyydsoft"
use-default-filters="false">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Service" />
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Repository" />
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Component" />
</context:component-scan>
<!--proxy-target-class="true"强制使用cglib代理 如果为false则spring会自动选择 -->
<aop:aspectj-autoproxy proxy-target-class="true" />

<!-- 数据库配置文件位置 -->
<context:property-placeholder location="classpath*:db.properties" />

<!-- destroy-method="close"的作用是当数据库连接不使用的时候,就把该连接重新放到数据池中,方便下次使用调用 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="" />
<property name="jdbcUrl" value="" />
<property name="user" value="" />
<property name="password" value="" />
</bean>

<!-- 使用jdbc 来管理事务 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>

<!-- 配置 mybatis 的sqlSessionFactory 由 spring 的 SqlSessionFactoryBean 代理 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动到mappers包下面去搜索mybatis的映射文件 -->
<!-- <property name="configLocation" value="classpath:mybatis-config.xml"
/> -->
<property name="mapperLocations" value="classpath*:com/fyydsoft/mapper/**/*.xml" />
<property name="typeAliasesPackage" value="com.fyydsoft.model" />

</bean>

<!-- 使用spring 的 SqlSessionTemplate 创建一个 可以批量操作的sqlSession -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>

<!-- 开启注解方式声明事务 -->
<tx:annotation-driven />

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.fyydsoft.dao">
</property>
</bean>

</beans>
追问
能不能帮我搭个项目?不只要application的配置
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式