解决方案 »
- 这是什么问题:本地时间正确,jsp页面的时间却晚了6个多小时?(Win7)
- 关于架构类似javaeye网站的可行性,路过的随便谈谈看法,就当接个分吧
- 送分啦,进来看看
- struts.xml问题
- TOMCAT和JIRA端口冲突问题
- struts1.2验证
- 100分!!!求助Servlet与jspSmartUpload、javascript脚本如何同时使用的问题。
- 哪裡可以找到corejava包?急啊
- 编译jsp文件时找不到class怎么办,我用的是Tomcat4.1
- 开发Applet JApplet小应用程序 现在开发过程中有什么好的调试方法吗?
- 在servlet中用什么方法获得ckeditor编辑器的内容(可能含有图片)
- C#客户端调用java Cxf webservice 参数问题
package com.skynet.cdw.platform.service;import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;import com.skynet.cdw.common.service.BaseService;
import com.skynet.cdw.platform.dao.ResourceDao;
import com.skynet.cdw.platform.entity.Resource;@Service
@Transactional
public class ResourceService implements BaseService<Resource, Integer>
{
@Autowired
private ResourceDao resourceDao; public List<Resource> findAll()
{
return resourceDao.findAll();
} public List<Resource> findById(Integer id)
{
// TODO Auto-generated method stub
return null;
}
@Transactional
public void save(Resource entity)
{
resourceDao.save(entity);
Resource res = new Resource();
res.setName("资源管理");
resourceDao.save(res);
} public void delete(Resource entity)
{
} public void delete(Integer id)
{
// TODO Auto-generated method stub
} public void update(Resource entity)
{
// TODO Auto-generated method stub
} public ResourceDao getResourceDao()
{
return resourceDao;
} public void setResourceDao(ResourceDao resourceDao)
{
this.resourceDao = resourceDao;
}
}
是的,没有任何错误,对于数据的只读操作都没有问题,数据都可以查询到,但是按照配置来看,save方法是有写权限的呀
<!-- 自动扫描的包名 -->
<context:component-scan base-package="com.skynet.cdw.platform.**" ></context:component-scan>
<!-- 默认的注解映射的支持 -->
<mvc:annotation-driven />
<!-- 视图解释类 -->
<bean id="freeerViewResolver" class="com.skynet.cdw.common.springmvc.SimpleFreeMarkerViewResolver">
<property name="suffix" value=".html"/>
<property name="contentType" value="text/html; charset=UTF-8"/>
<property name="exposeRequestAttributes" value="false"/>
<property name="exposeSessionAttributes" value="false"/>
<property name="exposeSpringMacroHelpers" value="true"/>
</bean>
<bean id="freeerConfig" class="org.springframework.web.servlet.view.freeer.FreeMarkerConfigurer">
<!-- 将页面模板定义到jar包下,模块化方便管理和扩展 -->
<property name="templateLoaderPath" value="/WEB-INF/page/admin/"/>
<property name="freeerVariables">
<map>
<!-- 将默认的根路径存入到request中 -->
<entry key="appBase" value="/admin/"/>
</map>
</property>
<property name="freeerSettings">
<props>
<prop key="template_update_delay">0</prop>
<prop key="defaultEncoding">UTF-8</prop>
<prop key="locale">zh_CN</prop>
<prop key="boolean_format">true,false</prop>
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
<prop key="date_format">yyyy-MM-dd</prop>
<prop key="time_format">HH:mm:ss</prop>
<prop key="number_format">0.######</prop>
<prop key="whitespace_stripping">true</prop>
<!-- <prop key="auto_import">/ftl/jeecms/index.ftl as p,/ftl/spring.ftl as s</prop> -->
</props>
</property>
</bean>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-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/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
"
default-lazy-init="false"> <description>Spring公共配置</description> <!-- 定义受环境影响易变的变量 -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName"
value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<!-- 数据库配置-->
<value>classpath*:jdbc.properties</value>
<!-- 系统配置 -->
<!-- <value>classpath*:config.properties</value> -->
</list>
</property>
</bean>
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan base-package="com.evo.bpc" annotation-config="true"/>
<!--自动扫描定时任务 -->
<task:annotation-driven/>
<!-- 数据源配置,使用应用内的DBCP数据库连接池 -->
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<!--Connection Info-->
<property name="driverClass" value="${jdbc.driver}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" /> <!--Connection Pooling Info to C3p0-->
<property name="acquireIncrement" value="${c3p0.acquireIncrement}" />
<property name="initialPoolSize" value="${c3p0.initialPoolSize}" />
<property name="maxPoolSize" value="${c3p0.maxPoolSize}" />
<property name="minPoolSize" value="${c3p0.minPoolSize}" />
<property name="maxIdleTime" value="${c3p0.maxIdleTime}" />
<property name="maxStatements" value="${c3p0.maxStatements}" />
<property name="maxStatementsPerConnection" value="${c3p0.maxStatementsPerConnection}" />
<property name="statementCacheNumDeferredCloseThreads" value="${c3p0.statementCacheNumDeferredCloseThreads}" /><!-- set to 1 -->
<property name="autoCommitOnClose" value="${c3p0.autoCommitOnClose}" />
</bean> <!-- Hibernate配置 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="namingStrategy">
<bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
<prop key="hibernate.format_sql">
${hibernate.format_sql}
</prop>
<prop key="hibernate.jdbc.fetch_size">
${hibernate.jdbc.fetch_size}
</prop>
<prop key="hibernate.jdbc.batch_size">
${hibernate.jdbc.batch_size}
</prop>
<prop key="hibernate.current._session_context_class">
thread
</prop>
<!--hibernate 是否使用二级缓存 预留在此 -->
<!--
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache/ehcache-hibernate-local.xml</prop> -->
</props>
</property>
<property name="packagesToScan" value="com.evo.bpc.entity" /> //扫描实体javabean
</bean> <!-- 事务管理器配置,单数据源事务 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<aop:aspectj-autoproxy />
<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />
</beans>以上 是 现在项目使用的
@Entity 扫描支持jpa
@Table(name = "admire")
public class Admire implements java.io.Serializable@Service
@Transactional 事务管理
public class AdmireServiceImpl implements AdmireService
@Controll
AdmireAction 很简单 请把 xml配置 和 自动扫描 分清楚
嗯嗯 您的意思我明白,当时发帖的时候换了一种方式测试的,所以service类里的事务标注就没有删除,不好意思。