spring + mybatis 事物不起作用,无法回滚

spring + mybatis 事物不起作用,无法回滚:求解

设置如下:

<aop:aspectj-autoproxy proxy-target-class="true" />

<!-- 基于Druid数据库链接池的数据源配置 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
    <property name="driverClassName" value="${jdbc.driver}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="initialSize" value="${pool.initialSize}" />
    <property name="minIdle" value="${pool.minIdle}" />
    <property name="maxActive" value="${pool.maxActive}" />
    <property name="maxWait" value="${pool.maxWait}" />
    <property name="timeBetweenEvictionRunsMillis" value="${pool.timeBetweenEvictionRunsMillis}" />
    <property name="minEvictableIdleTimeMillis" value="${pool.minEvictableIdleTimeMillis}" />
    <property name="testWhileIdle" value="true" />
    <property name="testOnBorrow" value="true" />
    <property name="testOnReturn" value="false" />
    <property name="validationQuery" value="${jdbc.validationQuery}" />
    <property name="filters" value="config" />
    <property name="connectionProperties" value="config.decrypt=true;config.decrypt.key=${jdbc.publickey}" />
</bean>

<!-- 将数据源映射到sqlSessionFactory中 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations" value="classpath*:mapper/*.Mapper.xml" />
    <property name="configLocation" value="classpath:config/mybatis-config.xml" />
</bean>

<!-- SqlSession模板类实例 -->
<bean id="sessionTemplate" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="close">
    <constructor-arg index="0" ref="sqlSessionFactory" />
</bean>

<!--======= 事务配置 Begin ================= -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
</bean>
<!-- <aop:pointcut id="txPointcut" expression="execution(* com.enjoy.system.service..*(..)) or execution(* com.enjoy.commodity.service..*(..))" /> -->

<aop:config>
    <aop:pointcut id="txPointcut" expression="(execution(* com.enjoy.system.service..*(..)) or execution(* com.enjoy.commodity.service..*(..)))" />
    <aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice" />
</aop:config>

<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="insert*" propagation="REQUIRED" />
        <tx:method name="save*" propagation="REQUIRED" />
        <tx:method name="add*" propagation="REQUIRED" />
        <tx:method name="set*" propagation="REQUIRED" />
        <tx:method name="update*" propagation="REQUIRED" />
        <tx:method name="edit*" propagation="REQUIRED" />
        <tx:method name="delete*" propagation="REQUIRED" />
        <tx:method name="remove*" propagation="REQUIRED" />
        <tx:method name="init*" propagation="REQUIRED" />
        <tx:method name="get*" propagation="REQUIRED" read-only="true" />
        <tx:method name="count*" propagation="REQUIRED" read-only="true" />
        <tx:method name="find*" propagation="REQUIRED" read-only="true" />
        <tx:method name="list*" propagation="REQUIRED" read-only="true" />
        <tx:method name="*" read-only="true" />
    </tx:attributes>
</tx:advice>

求解!!

3个回答

看上去配置没有问题,贴一下java代码和日志
是不是service中的方法名不是以你配置的方法名开头的
可以看下这篇文章:http://58coding.com/article/detail/24667919514339873

你的包是不是导入的全和正确

service层:

package com.enjoy.commodity.service;

import java.util.List;
import java.util.Map;

import com.enjoy.commodity.entity.CommodityImage;

public interface CommodityImageService {

/**
 * 保存信息.
 * 
 * @param bean
 */
public void insert(CommodityImage entity);

/**
 * 批量保存
 * @param list
 */
public void insert(List<CommodityImage> list);

/**
 * 更新信息.
 * 
 * @param user
 */
public void update(CommodityImage entity);

/**
 * 根据ID获取信息.
 * 
 * @param userId
 * @return
 */
public CommodityImage getById(Long id);

/**
 * 根据ID删除
 * 
 * @param id 
 */
public void deleteById(Long id);

/**
 * 根据id批里删除
 * @param list
 */
public void deleteByIds(List<Map<String, Object>> list);

/**
 * 得到商品图片
 * @param map commodityid
 * @return
 */
public List<CommodityImage> listBy(Map<String, Object> map);

/**
 * 得到商品图片条数
 * @param map
 * @return
 */
public Long getCountByColumn(Map<String, Object> map);

}
图片说明

包也是对上的没有错误信息

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
spring + mybatis 事物不起作用,无法回滚
spring + mybatis 事物不起作用,无法回滚:求解 设置如下: <!-- proxy-target-class默认"false",更改为"ture"使用CGLib动态代理 --> <aop:aspectj-autoproxy proxy-target-class="true" /> <!-- 基于Druid数据库链接池的数据源配置 --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="initialSize" value="${pool.initialSize}" /> <property name="minIdle" value="${pool.minIdle}" /> <property name="maxActive" value="${pool.maxActive}" /> <property name="maxWait" value="${pool.maxWait}" /> <property name="timeBetweenEvictionRunsMillis" value="${pool.timeBetweenEvictionRunsMillis}" /> <property name="minEvictableIdleTimeMillis" value="${pool.minEvictableIdleTimeMillis}" /> <property name="testWhileIdle" value="true" /> <property name="testOnBorrow" value="true" /> <property name="testOnReturn" value="false" /> <property name="validationQuery" value="${jdbc.validationQuery}" /> <property name="filters" value="config" /> <property name="connectionProperties" value="config.decrypt=true;config.decrypt.key=${jdbc.publickey}" /> </bean> <!-- 将数据源映射到sqlSessionFactory中 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mapperLocations" value="classpath*:mapper/*.Mapper.xml" /> <property name="configLocation" value="classpath:config/mybatis-config.xml" /> </bean> <!-- SqlSession模板类实例 --> <bean id="sessionTemplate" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="close"> <constructor-arg index="0" ref="sqlSessionFactory" /> </bean> <!--======= 事务配置 Begin ================= --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- <aop:pointcut id="txPointcut" expression="execution(* com.enjoy.system.service..*(..)) or execution(* com.enjoy.commodity.service..*(..))" /> --> <aop:config> <aop:pointcut id="txPointcut" expression="(execution(* com.enjoy.system.service..*(..)) or execution(* com.enjoy.commodity.service..*(..)))" /> <aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice" /> </aop:config> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="insert*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="set*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="edit*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="init*" propagation="REQUIRED" /> <tx:method name="get*" propagation="REQUIRED" read-only="true" /> <tx:method name="count*" propagation="REQUIRED" read-only="true" /> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="list*" propagation="REQUIRED" read-only="true" /> <tx:method name="*" read-only="true" /> </tx:attributes> </tx:advice> 求解!!
spring+mybatis事物配置的问题
昨天遇到一个有关事物方面的问题,请大家帮忙看看,问题出在了什么地方,谢谢! 具体问题描述:根据B表同步A表的数据,结果service方法返回后B表的数据已处理标志没有更新,程序在第二次同步数据时B表的数据才能更新。具体情况见下面代码的注释。 事物配置文件: > <tx:advice id="txAdvice" transaction-manager="transactionManager"> > <tx:attributes> <tx:method name="*" read-only="true" /> > <tx:method name="add*" propagation="REQUIRED" > rollback-for="java.lang.Exception" /> <tx:method name="save*" > propagation="REQUIRED" rollback-for="java.lang.Exception" /> > <tx:method name="modify*" propagation="REQUIRED" > rollback-for="java.lang.Exception" /> <tx:method name="update*" > propagation="REQUIRED" rollback-for="java.lang.Exception" /> > <tx:method name="delete*" propagation="REQUIRED" > rollback-for="java.lang.Exception" /> <tx:method name="syn*" > propagation="REQUIRED" rollback-for="java.lang.Exception" /> > </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="execution(* com.mdc.jiangsu114weixinServer.service..*.*(..))" id="transactionPointCut" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointCut" /> </aop:config> service中的方法: public List<MerchantSyn> getPageData(Page page){ List<MerchantSyn> list =this.merchantSynMapper.merchantsynInfoListPage(page); return list; } public void synchronizeMerchant(MerchantSyn merchantSyn) { //判断A表是否有数据,如果有则更新,没有则插入数据 int count = merchantSynMapper.getMerchantCount(merchantSyn); if(count>0){ merchantSynMapper.updateMerchantData(merchantSyn); }else{ merchantSynMapper.insertMerchantData(merchantSyn); } //更新B表的数据 //该方法第一次执行完时,下面的语句没有把表中的数据SynFlag更新, //但,第二次该方法执行完时,下面的语句把数据库中的字段SynFlag更新了 merchantSyn.setSynFlag("1"); merchantSynMapper.updateMerchantSynDealFlag(merchantSyn); } controller中调用service中的方法: Page page = new Page(); page.setCurrentPage(1); page.setPageSize(20); page.setEntityOrField(true); //只有一条测试数据 List<MerchantSyn> list = this.merchantSynService.getPageData(page); if(list!=null && list.size()>0){ while(list.size()>0){ for(int i=0;i<list.size();i++){ this.merchantSynService.synchronizeMerchant(list.get(i)); } //由于第一次SynFlag没有更新,所以下面的语句还会查询到数据,即会进行第二次调用方法synchronizeMerchant(..); list = this.merchantSynService.getPageData(page); if(list==null || list.size()<=0){ break; } } }
spring MVC+mybatis 代码中进行事物回滚,请高手指点
前提:![图片说明](https://img-ask.csdn.net/upload/201606/06/1465196836_156827.png) 这个是要报错了才会回滚 我现在想在这个基础上面,在无异常的情况下用代码进行回滚 比如我现在将数据插入到主表了,在插入子表的时候,我发现子表数据的数据有不合法的,这不会产生异常,单纯的数据是我不想要的,我进行回滚 比如现在:主表已插入了一条数据,子表已插入三条数据,在插入第四条的时候,我觉得第四条数据不是我想要的(无异常情况),我用代码进行回滚。 我现在代码中使用: TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 无法回滚。 有谁知道怎么回滚啊?望告知
springMVC+Spring+Mybatis整合出错
``` 八月 29, 2017 2:47:19 下午 org.apache.catalina.startup.HostConfig reload 信息: Reloading context [/SpringMVC] 八月 29, 2017 2:47:19 下午 org.apache.catalina.startup.HostConfig reload 警告: Error during context [/SpringMVC] restart org.apache.catalina.LifecycleException: Failed to initialize component [org.apache.catalina.webresources.JarResourceSet@35dc37a6] at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:441) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:139) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:173) at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:724) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4758) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4893) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.HostConfig.reload(HostConfig.java:1413) at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1377) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1613) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:304) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1172) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1394) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1398) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1366) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalArgumentException: java.util.zip.ZipException: invalid END header (bad central directory offset) at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:114) at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136) ... 16 more Caused by: java.util.zip.ZipException: invalid END header (bad central directory offset) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:225) at java.util.zip.ZipFile.<init>(ZipFile.java:155) at java.util.jar.JarFile.<init>(JarFile.java:166) at java.util.jar.JarFile.<init>(JarFile.java:103) at org.apache.catalina.webresources.AbstractSingleArchiveResourceSet.initInternal(AbstractSingleArchiveResourceSet.java:111) ... 17 more ``` 以上是tomcat的错误信息,根据在网上的搜索,我检查了web.xml和build_path,都是好好的,对dao层和service层的测试也均正常,下面我贴出web.xml的代码和application.xml的配置 ``` <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1"> <display-name>SpringMVC</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <servlet-name>dispatcherServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:dispatcherServlet-servlet.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> </web-app> ``` application.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: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/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"> <!-- 开启组件扫描 --> <context:component-scan base-package="com.xiaolei"></context:component-scan> <!--开启注解处理器--> <context:annotation-config></context:annotation-config> <!--数据源配置--> <bean id="dataSource" 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/springmvc"/> <!-- 用户名 --> <property name="username" value="root"/> <!-- 密码 --> <property name="password" value="cl19951003"/> </bean> <!-- 配置Mybatis的文件 ,mapperLocations配置**Mapper.xml文件位置,configLocation配置mybatis-config文件位置--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:configuration.xml"/> </bean> <!-- 自动扫描了所有的XxxxMapper.xml对应的mapper接口文件,这样就不用一个一个手动配置Mpper的映射了, 只要Mapper接口类和Mapper映射文件对应起来就可以了 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.xiaolei.daoInterface"/> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/> </bean> <!-- 事物管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <tx:annotation-driven transaction-manager="transactionManager"/> </beans> ``` dispatcherServlet-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/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 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"> <!-- 扫描所有的 controller --> <context:component-scan base-package="com.xiaolei.controller" /> <!-- 启动注解驱动 SpringMVC 功能 --> <mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="WEB-INF/jsp/" /> <property name="suffix" value=".jsp" /> </bean> </beans> ``` 如果还需要别的代码,请您回复我,跪求大神帮看看这是什么问题,跪谢!
spring MVC+mybatis 在代码中怎么进行事物回滚?请高手指点
前提是:我已经在spring xml配置了事物管理 ![图片说明](https://img-ask.csdn.net/upload/201606/06/1465196571_745136.png) 这个是要报错了才会回滚 我现在想在这个基础上面,在无异常的情况下用代码进行回滚 比如我现在将数据插入到主表了,在插入子表的时候,我发现子表数据的数据有不合法的,这不会产生异常,单纯的数据是我不想要的,我进行回滚 比如现在:主表已插入了一条数据,子表已插入三条数据,在插入第四条的时候,我觉得第四条数据不是我想要的(无异常情况),我用代码进行回滚。 我现在代码中使用: TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 无法回滚。 有谁知道怎么回滚啊?望告知
spring+mybatis发布webservice接口问题
用spring+mybatis写的一个web项目,bean的管理是通过spring自动注入实现,在项目中可以实现对持久层dao的操作,并且@Transactional事物管理有效,但是将接口发布成webservice接口(用eclipse自带jax-ws实现),接口发布成功,但是在调用方法的候webservice获取不到spring注入的bean。 换一种方式(方式2),将接口中需要的bean,通过ApplicationContext getbean()获取bean实例,然后在发布webservice接口,能够实现对持久层dao的操作,但是事物失效这个问题有什么解决方案。 问题一:webservice怎么能实现spring注入的bean不为空。 问题二:用getBean的方式(方式2)发布的webservice怎么解决事物失效问题。
spring-boot+mybatis @Transactional事务管理不起作用
# 问题描述: * services代码如下,运行后第一条insert语句(小明)插入表中,第二条insert(小王)未插入表中 ``` @Service public class UserInfoServiceImpl implements IUserInfoService { @Override @Transactional public List<User> listUser() { userDao.insert(new User(100001,"小明","123","123321123")); int a = 1/0; //测试事物管理 userDao.insert(new User(400001,"小王","123","123321123")); return userDao.listUserInfo(); } } ``` # 问题背景: ## 1. spring-boot + mybatis + jdk8 ## 2. 数据库mysql,表引擎为:InnoDB,项目以普通用户连接数据库 ## 3. 事务管理已开启 ``` import org.springframework.transaction.annotation.EnableTransactionManagement; @EnableTransactionManagement @SpringBootApplication public class SmdemoApplication { public static void main(String[] args) { SpringApplication.run(SmdemoApplication.class, args); } } ``` ## 4. services类有注解,对应方法为public,方法内容未捕获异常,该方法由外部类调用 ``` @Service public class UserInfoServiceImpl implements IUserInfoService { @Resource private UserMapper userDao; @Override @Transactional(rollbackFor=Exception.class) public List<User> listUser() { userDao.insert(new User(100001,"小明","123","123321123")); int a = 1/0; userDao.insert(new User(400001,"小明","123","123321123")); return userDao.listUserInfo(); } } ``` 在网上找到的所有方法都试过了,均无效,还请高手赐教。
springboot2.0+mybatis+jta+automatic 事物不回滚?
springboot2.0+mybatis+jta+automatic配置双数据源事物管理,配置完事物操作第二个数据源时报错事物不回滚。 运行时提示:atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@2db2fd16: WARNING: transaction manager not running? application.yml配置如下 spring: jta: enabled: true transaction-manager-id: txManager datasource: master: xa-properties: url: jdbc:mysql://127.0.0.1:3308/mytest??useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&pinGlobalTxToPhysicalConnection=true username: root password: "123456" driverClassName: com.mysql.jdbc.Driver unique-resource-name: masterDataSource xa-data-source-class-name: com.alibaba.druid.pool.xa.DruidXADataSource max-pool-size: 25 min-pool-size: 3 max-lifetime: 20000 borrow-connection-timeout: 10000 second: xa-properties: url: jdbc:mysql://127.0.0.1:3308/mytest2??useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&pinGlobalTxToPhysicalConnection=true username: root password: "123456" driverClassName: com.mysql.jdbc.Driver xa-data-source-class-name: com.alibaba.druid.pool.xa.DruidXADataSource unique-resource-name: secondDataSource max-pool-size: 25 min-pool-size: 3 max-lifetime: 20000 borrow-connection-timeout: 10000 @Configuration @MapperScan(basePackages = "com.mv.dao.master", sqlSessionTemplateRef = "masterSqlSessionTemplate") public class MasterDataSourceConfig { /** * 创建主库数据源 * @return */ @Bean(name = "masterDataSource") @ConfigurationProperties(prefix = "spring.datasource.master") @Primary public DataSource masterDataSource() { AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean(); atomikosDataSourceBean.setUniqueResourceName("masterDataSource"); return atomikosDataSourceBean; } @Configuration @MapperScan(basePackages = "com.mv.dao.second", sqlSessionTemplateRef = "secondSqlSessionTemplate") public class SecondDataSourceConfig { /** * 创建主库数据源 * @return */ @Bean(name = "secondDataSource") @ConfigurationProperties(prefix = "spring.datasource.second") public DataSource secondDataSource() { AtomikosDataSourceBean atomikosDataSourceBean = new AtomikosDataSourceBean(); atomikosDataSourceBean.setUniqueResourceName("secondDataSource"); return atomikosDataSourceBean; } 2019-03-20 17:24:28.459 INFO 37520 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started 2019-03-20 17:24:28.482 INFO 37520 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 23 ms 2019-03-20 17:24:28.523 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@2db2fd16: WARNING: transaction manager not running? 2019-03-20 17:24:28.523 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@2db2fd16: WARNING: transaction manager not running? 2019-03-20 17:24:28.547 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@209eddac: WARNING: transaction manager not running? 2019-03-20 17:24:28.548 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@209eddac: WARNING: transaction manager not running? 2019-03-20 17:24:28.548 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@209eddac: WARNING: transaction manager not running? 2019-03-20 17:24:28.574 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@209eddac: WARNING: transaction manager not running? 2019-03-20 17:24:28.577 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@2db2fd16: WARNING: transaction manager not running? 2019-03-20 17:24:28.577 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@2db2fd16: WARNING: transaction manager not running? 2019-03-20 17:24:28.625 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@2db2fd16: WARNING: transaction manager not running? 2019-03-20 17:24:28.626 WARN 37520 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy : atomikos connection proxy for com.mysql.jdbc.JDBC4Connection@2db2fd16: WARNING: transaction manager not running? 2019-03-20 17:24:28.657 ERROR 37520 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing
spring mvc 同时集成 mybatis 和 jpa ,事务是否一致
由于种种原因,项目中需要同时继承mybatis,和 jpa,有个疑问是 使用mybatis 的service 调用 jpa 实现的 service ,事务是否会生效,即 两个service 是否用的同一个事物,事务管理使用spring 的声明式事务, 使用 @Transactional 注解。
至急的一个问题,关于spring3.12+ mybatis的事物控制
遇到一个很急的问题,我用的是声明式事务。 <br />样式参照论坛的涛ge的代码,有这样一个需求,比如在下面的代码中,假如save方法中的 <br />如果address 是 aaaa,那么要求事物强制回滚掉,这个地方该怎么解决啊 <br /> <br />package cn.javass.spring.chapter9.service.impl; <br />//省略import <br />public class AnnotationUserServiceImpl implements IUserService { <br />... <br />&nbsp;&nbsp;&nbsp; @Transactional(propagation=Propagation.REQUIRED, isolation=Isolation.READ_COMMITTED) <br />&nbsp;&nbsp;&nbsp; @Override <br />&nbsp;&nbsp;&nbsp; public void save(final UserModel user) { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; userDao.save(user); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ("aaaa".equals(user.getAddress())){ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // 事物要求回滚 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这个地方的代码怎么写?,如何将事物强制回滚掉? <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addressService.save(user.getAddress()); <br /> <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp; <br />}
springboot整合mybatis-plus无法映射xml文件
异常信息: ```org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)``` 异常原因排除: 1. 项目正常启动 2. mybaits-plus配置mapper.xml扫描没问题 ```xml mybatis-plus: # 配置扫描xml mapper-locations: classpath*:mapper/*/*Mapper.xml # 实体扫描,多个package用逗号或者分号分隔 type-aliases-package: org.cnplo.control.modules.admin.domain ``` 3. mapperscan扫描mapper正常 4.mybatis-plus的配置文件 MybatisPlusConfig配置 ```java @Configuration @MapperScan("org.cnplo.control.modules.*.mapper") public class MybatisPlusConfig { /** * 乐观锁插件 */ @Bean public OptimisticLockerInterceptor optimisticLockerInterceptor() { return new OptimisticLockerInterceptor(); } /** * mybatis-plus分页插件 */ @Bean public PaginationInterceptor paginationInterceptor() { return new PaginationInterceptor(); } } ``` DruidDataSourceConfig配置 ```java @Configuration public class DruidDataSourceConfig { /** * @return DruidDataSource */ @Bean @ConfigurationProperties(prefix = "spring.datasource") public DruidDataSource druidDataSource() { return new DruidDataSource(); } /** * 配置事物管理器 */ @Bean public DataSourceTransactionManager transactionManager() { return new DataSourceTransactionManager(druidDataSource()); } } ``` 项目正常启动,执行数据库请求的时候异常BindingException。请问这是什么问题,大胆猜测是哪个jar包升级引起的,还请大佬们不吝赐教 ``` <properties> <java.version>1.8</java.version> <json.version>1.2.54</json.version> <druid.version>1.1.20</druid.version> <swagger.version>2.7.0</swagger.version> <mybatisplus.version>3.3.1.tmp</mybatisplus.version> </properties> <dependencies> <!--web--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--lombok--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <!--druid--> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- mybatisplus与springboot整合 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatisplus.version}</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>${mybatisplus.version}</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-autoconfigure</artifactId> <version>1.3.2</version> </dependency> <!-- swagger2 rest api start--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>${swagger.version}</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>${swagger.version}</version> </dependency> <!--json工具--> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>${json.version}</version> </dependency> <!-- jwt --> <dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>0.9.1</version> </dependency> <!--redis--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency> <!--thymeleaf--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!--test--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> ```
求助 spirng+Druid+mybatis 批量更新后 事物无法提交,一下是报错的全部日志
[ERROR] com.yazuo.ipos.chains.exception.handler.GlobalExceptionHandler 80 : class com.yazuo.ipos.chains.controller.scm.ScmInController.finishScmIn error! org.springframework.transaction.TransactionSystemException: Could not commit JDBC transaction; nested exception is java.sql.SQLException: connection holder is null
Mybatis + SpringData-Jpa 事物提交问题
现在有两个Maven工程,工程A使用mybatis,单独配置了一套transactionManager, 工程B使用SpringData-Jpa,也单独配置了一套transactionManager,两个工程使用mysql同一数据库。 在工程B中引用了工程A,然后通过调用工程A的deleteService发现事物不能提交,查询数据是ok的,并且deleteService的sql都可以正常打印,只是没有提交事物。 **但是工程A单独运行时没有该问题**。 # 以下是工程A数据源配置文件信息: <?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:tx="http://www.springframework.org/schema/tx" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop" 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/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 引入properties配置文件 --> <context:property-placeholder ignore-unresolvable="true" location="classpath*:logic.properties" /> <!-- 扫描路径 --> <context:component-scan base-package="logic"> </context:component-scan> <context:annotation-config /> <!-- 可通过注解设置Spring Task --> <task:annotation-driven /> <aop:aspectj-autoproxy proxy-target-class="true"> </aop:aspectj-autoproxy> <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> <property name="corePoolSize" value="${task.core_pool_size}" /> <property name="maxPoolSize" value="${task.max_pool_size}" /> <property name="queueCapacity" value="${task.queue_capacity}" /> <property name="keepAliveSeconds" value="${task.keep_alive_seconds}" /> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.classname}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="maxActive" value="20" /> <property name="initialSize" value="1" /> <property name="maxWait" value="60000" /> <property name="maxIdle" value="20" /> <property name="removeAbandoned" value="true" /> <property name="removeAbandonedTimeout" value="180" /> <property name="minIdle" value="3" /> <property name="testWhileIdle" value="true" /> <property name="testOnBorrow" value="false" /> <property name="testOnReturn" value="false" /> <property name="validationQuery" value="SELECT NOW()" /> <property name="validationQueryTimeout" value="1" /> <property name="timeBetweenEvictionRunsMillis" value="30000" /> <property name="numTestsPerEvictionRun" value="20" /> <property name="defaultAutoCommit" value="false" /> </bean> <!-- 创建SqlSessionFactory,同时指定数据源 --> <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mapperLocations" value="classpath*:logic/*/mapper/xml/*.xml" /> </bean> <!-- 事务管理 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 开启注解管理事物 --> <tx:annotation-driven transaction-manager="transactionManager" /> <!-- Mapper接口所在包名,Spring会自动查找其下的Mapper --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sessionFactory" /> <property name="basePackage" value="logic.*.mapper" /> </bean> </beans> # 以下是工程B数据源配置文件信息: <?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:tx="http://www.springframework.org/schema/tx" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:task="http://www.springframework.org/schema/task" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:cache="http://www.springframework.org/schema/cache" 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/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> <bean id="mainDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.classname}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="maxActive" value="20" /> <property name="initialSize" value="1" /> <property name="maxWait" value="60000" /> <property name="maxIdle" value="20" /> <property name="removeAbandoned" value="true" /> <property name="removeAbandonedTimeout" value="180" /> <property name="minIdle" value="3" /> <property name="testWhileIdle" value="true" /> <property name="testOnBorrow" value="false" /> <property name="testOnReturn" value="false" /> <property name="validationQuery" value="SELECT NOW()" /> <property name="validationQueryTimeout" value="1" /> <property name="timeBetweenEvictionRunsMillis" value="30000" /> <property name="numTestsPerEvictionRun" value="20" /> <property name="defaultAutoCommit" value="false" /> </bean> <cache:annotation-driven cache-manager="cacheManager" /> <bean id="ehCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath:/ehcache.xml" /> <property name="shared" value="true" /> </bean> <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"> <property name="cacheManager" ref="ehCacheManager" /> </bean> <bean id="adminEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="mainDataSource" /> <property name="packagesToScan" value="admin.entity" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="generateDdl" value="false" /> <property name="databasePlatform" value="org.hibernate.dialect.MySQL5InnoDBDialect" /> <property name="database" value="MYSQL" /> </bean> </property> <property name="jpaProperties"> <props> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.format_sql">true</prop> </props> </property> </bean> <!-- SPRING - JPA --> <bean class="org.springframework.orm.jpa.JpaTransactionManager" id="adminTransactionManager"> <property name="entityManagerFactory" ref="adminEntityManagerFactory" /> <property name="jpaDialect"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /> </property> </bean> <tx:annotation-driven transaction-manager="adminTransactionManager" /> <jpa:repositories base-package="admin.repository" entity-manager-factory-ref="adminEntityManagerFactory" transaction-manager-ref="adminTransactionManager"></jpa:repositories> </beans>
springboot,activiti,mybatis通用mapper集成?
求教 springboot集成activiti按照默认配置可以运行,但加入mybatis通用mapper后会出现如下的错误,求教该怎么配置呢: 启动错误: ~~~log org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.persistence.EntityManagerFactory' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.example.demo.Demo1Application.main(Demo1Application.java:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 6086 [main] DEBUG o.s.b.d.LoggingFailureAnalysisReporter - Application failed to start due to an exception org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.persistence.EntityManagerFactory' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) at com.example.demo.Demo1Application.main(Demo1Application.java:12) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) 2017-12-01 10:42:32.754 ERROR 13120 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Parameter 1 of method springProcessEngineConfiguration in org.activiti.spring.boot.JpaProcessEngineAutoConfiguration$JpaConfiguration required a bean of type 'javax.persistence.EntityManagerFactory' that could not be found. Action: Consider defining a bean of type 'javax.persistence.EntityManagerFactory' in your configuration. ~~~ 配置spring: ~~~ server.port=9090 # mysql spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.username=root spring.datasource.password=123456 spring.datasource.url=jdbc:mysql://127.0.0.1/test?enableUnicode=true&characterEncoding=UTF-8 mybatis.type-aliases-package=com.example.demo.model mybatis.mapper-locations=classpath:mappers/*.xml # mapper mapper.mappers=com.example.demo.util.MyMapper mapper.not-empty=false mapper.identity=MYSQL ~~~ activiti.cfg.xml ~~~xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" 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 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource"> <property name="driverClass" value="${spring.datasource.driver-class-name}" /> <property name="url" value="${spring.datasource.url}" /> <property name="username" value="${spring.datasource.username}" /> <property name="password" value="${spring.datasource.password}" /> </bean> <!-- 定义事物管理 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!-- 定义流程引擎配置 --> <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"> <property name="dataSource" ref="dataSource"/> <property name="transactionManager" ref="transactionManager"/> <property name="databaseSchemaUpdate" value="true"/> <property name="enableDatabaseEventLogging" value="false"/> <property name="jpaHandleTransaction" value="false"/> </bean> <!-- 定义流程引擎 --> <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean"> <property name="processEngineConfiguration" ref="processEngineConfiguration"/> </bean> <!-- 定义Service服务 --> <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService"/> <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService"/> <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"/> <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/> <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService"/> <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"/> <bean id="formService" factory-bean="processEngine" factory-method="getFormService"/> </beans> ~~~
spring AOP 拦截器方式配置事务失效
Spring.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" 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 "> <!-- 引入属性文件 --> <context:property-placeholder location="classpath:config.properties" /> <!-- 自动扫描dao和service包(自动注入) --> <context:component-scan base-package="com.zfy.db.dao,com.zfy.service" /> </beans> spring-mybatis.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:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd "> <!-- JNDI方式配置数据源 --><!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="${jndiName}"></property> </bean> --><!-- 配置数据源 --> <bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="url" value="${jdbc_url}" /> <property name="username" value="${jdbc_username}" /> <property name="password" value="${jdbc_password}" /> <property name="initialSize" value="0" /> <property name="maxActive" value="20" /> <property name="maxIdle" value="20" /> <property name="minIdle" value="0" /> <property name="maxWait" value="60000" /> <property name="validationQuery" value="${validationQuery}" /> <property name="testOnBorrow" value="false" /> <property name="testOnReturn" value="false" /> <property name="testWhileIdle" value="true" /> <property name="timeBetweenEvictionRunsMillis" value="60000" /> <property name="minEvictableIdleTimeMillis" value="25200000" /> <property name="removeAbandoned" value="true" /> <property name="removeAbandonedTimeout" value="1800" /> <property name="logAbandoned" value="true" /> <property name="filters" value="mergeStat" /> </bean> <!-- myBatis文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 --> <property name="mapperLocations"> <array> <value>classpath:com/zfy/mapper/portal/*.xml</value> <value>classpath:com/zfy/mapper/permission/*.xml</value> <value>classpath:com/zfy/mapper/form/*.xml</value> </array> </property> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.zfy.db.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" /> </bean> <!-- 拦截器方式配置事物 --> <tx:advice id="transactionAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="add*" propagation="REQUIRED" /> <tx:method name="append*" propagation="REQUIRED" /> <tx:method name="insert*" propagation="REQUIRED" rollback-for="java.lang.Exception"/> <tx:method name="save*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="modify*" propagation="REQUIRED" /> <tx:method name="edit*" propagation="REQUIRED" /> <tx:method name="delete*" propagation="REQUIRED" /> <tx:method name="remove*" propagation="REQUIRED" /> <tx:method name="repair" propagation="REQUIRED" /> <tx:method name="delAndRepair" propagation="REQUIRED" /> <tx:method name="get*" propagation="SUPPORTS" /> <tx:method name="find*" propagation="SUPPORTS" /> <tx:method name="load*" propagation="SUPPORTS" /> <tx:method name="all*" propagation="SUPPORTS" /> <tx:method name="search*" propagation="SUPPORTS" /> <tx:method name="datagrid*" propagation="SUPPORTS" /> <tx:method name="*" propagation="SUPPORTS" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="transactionPointcut" expression="execution(* com.zfy.service..*.*impl.*(..))" /> <aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" /> </aop:config> <!-- 配置druid监控spring jdbc --> <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"> </bean> <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype"> <property name="patterns"> <list> <value>com.zfy.service.*</value> </list> </property> </bean> <aop:config> <aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut" /> </aop:config> </beans> 项目架构 DAO接口: com.zfy.db.dao.form.FormSubjectMapper package com.zfy.db.dao.form; import com.zfy.db.model.form.FormSubject; public interface FormSubjectMapper { int insert(FormSubject record); } Service : com.zfy.service.form.FormSubjectService package com.zfy.service.form; import com.zfy.db.model.form.FormSubject; /** * @author keke * @version 创建时间:2013-5-15 下午11:05:45 * */ public interface FormSubjectService { public int insert(FormSubject record) throws Exception; } ServiceImpl: com.zfy.service.form.impl.FormSubjectServiceImpl package com.zfy.service.form.impl; import com.zfy.db.model.form.FormSubject; public int insert(FormSubject record){ FormSubject fs = new FormSubject(); fs.setFormCode(3); fs.setFormName("张三123"); for (int i = 0; i <2; i++) { mapper.insert(fs); } return 0; } } mybatis 配置文件 FormSubjectMapper.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.zfy.db.dao.form.FormSubjectMapper" > <resultMap id="BaseResultMap" type="com.zfy.db.model.form.FormSubject" > <id column="FORM_CODE" property="formCode" jdbcType="INTEGER" /> <result column="FORM_NAME" property="formNam" jdbcType="VARCHAR" /> </resultMap> <insert id="insert" parameterType="com.zfy.db.model.form.FormSubject" > insert into FORM_SUBJECT (FORM_CODE, FORM_NAME) values (#{formCode,jdbcType=INTEGER}, #{formName,jdbcType=VARCHAR}) </insert> </mapper> Junit 测试类: @Test public void test1() throws Exception{ try { formSubjectService.insert( null); }} catch (RuntimeException e) { e.printStackTrace(); } } 开发路线: Spring3.1 mybatis 3.1 运行之后。“张三”是插入进去了,但“李四 ”存在 违反唯一约束条件,没有回滚,所以事务没有起到作用。请大家帮忙看看。谢谢啦! 在线等……
重复的事务标识,求解决方案,框架:springMVC+mybatis,数据库oracle
项目总是隔两天报一次错误:重复的事物标识,报错的sql总是涉及到 使用 db_link的sql语句,重启项目后就好了,求高手解答!!! 报错内容如下: ``` HTTP Status 500 - Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: type Exception report message Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: description The server encountered an internal error that prevented it from fulfilling this request. exception org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: ### Error querying database. Cause: java.sql.SQLException: ORA-24757: 重复的事务处理标识 ORA-02063: 紧接着 line (起自 XBZHPDB) ### The error may exist in file [C:\tomcat\apache-tomcat-7.0.70\webapps\webApi\WEB-INF\classes\com\petrochina\mapping\StaypxsjhMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT nvl(sum(A.XSL/A.ZB),0) FROM (SELECT nvl(sum(QY_PFWCL+ QY_LSWCL+CY_PFWCL+ CY_LSWCL),0) as XSL,MZXNJG, (select AREA_SCZB FROM BASE_PROVINCIAL_AREA@xbzhpdb WHERE AREA_SQBM = MZXNJG) as ZB FROM STA_YPXSJH_WC WHERE to_char(CALDAY,'yyyy-mm-dd') BETWEEN ? and ? GROUP BY MZXNJG) A WHERE A.ZB is not null ### Cause: java.sql.SQLException: ORA-24757: 重复的事务处理标识 ORA-02063: 紧接着 line (起自 XBZHPDB) ; uncategorized SQLException for SQL []; SQL state [99999]; error code [24757]; ORA-24757: 重复的事务处理标识 ORA-02063: 紧接着 line (起自 XBZHPDB) ; nested exception is java.sql.SQLException: ORA-24757: 重复的事务处理标识 ORA-02063: 紧接着 line (起自 XBZHPDB) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) javax.servlet.http.HttpServlet.service(HttpServlet.java:624) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) root cause org.springframework.jdbc.UncategorizedSQLException: ### Error querying database. Cause: java.sql.SQLException: ORA-24757: 重复的事务处理标识 ORA-02063: 紧接着 line (起自 XBZHPDB) ### The error may exist in file [C:\tomcat\apache-tomcat-7.0.70\webapps\webApi\WEB-INF\classes\com\petrochina\mapping\StaypxsjhMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT nvl(sum(A.XSL/A.ZB),0) FROM (SELECT nvl(sum(QY_PFWCL+ QY_LSWCL+CY_PFWCL+ CY_LSWCL),0) as XSL,MZXNJG, (select AREA_SCZB FROM BASE_PROVINCIAL_AREA@xbzhpdb WHERE AREA_SQBM = MZXNJG) as ZB FROM STA_YPXSJH_WC WHERE to_char(CALDAY,'yyyy-mm-dd') BETWEEN ? and ? GROUP BY MZXNJG) A WHERE A.ZB is not null ### Cause: java.sql.SQLException: ORA-24757: 重复的事务处理标识 ORA-02063: 紧接着 line (起自 XBZHPDB) ; uncategorized SQLException for SQL []; SQL state [99999]; error code [24757]; ORA-24757: 重复的事务处理标识 ORA-02063: 紧接着 line (起自 XBZHPDB) ; nested exception is java.sql.SQLException: ORA-24757: 重复的事务处理标识 ORA-02063: 紧接着 line (起自 XBZHPDB) org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84) org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81) org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371) com.sun.proxy.$Proxy13.selectOne(Unknown Source) org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:163) org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68) org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52) com.sun.proxy.$Proxy30.queryShengTotalZhanBi(Unknown Source) com.petrochina.service.impl.staypxsjhServiceImpl.XBWL_scgk(staypxsjhServiceImpl.java:383) com.petrochina.controller.HomeController.XBWL_scgk(HomeController.java:1041) sun.reflect.GeneratedMethodAccessor146.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:498) org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690) org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) javax.servlet.http.HttpServlet.service(HttpServlet.java:624) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.70 logs. Apache Tomcat/7.0.70 ```
对于SSI中的action的数据回滚的疑问
<p>最近看了公司的一个框架,很是不明白。框架是用struts,spring,mybatis搭建起来的。简化下就是三层,action,service,dao。事物控制放在了service层。action层只负责页面跳转,以及调用service层。<br>可是如果一个请求,在service层执行成功后,在action负责跳转的时候产生了一个异常。这个时候数据已经写入到了数据库,我该如何将写入的数据回滚呢?或者我如何修改这个框架的配置。<br><br>spring的配置如下:</p> <pre name="code" class="java">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;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-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-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/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt; &lt;property name="username" value="root" /&gt; &lt;property name="password" value="123456" /&gt; &lt;property name="url" value="jdbc:mysql://127.0.0.1:3306/ci" /&gt; &lt;/bean&gt; &lt;!-- define the SqlSessionFactory --&gt; &lt;bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="typeAliasesPackage" value="com.leopardsnow.ci.domain" /&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;/bean&gt; &lt;context:component-scan base-package="com.leopardsnow.ci.service" /&gt; &lt;context:annotation-config /&gt; &lt;tx:annotation-driven /&gt; &lt;!-- 从base 包中搜索所有下面所有 interface,并将其注册到 Spring Bean容器中,其注册的class bean是MapperFactoryBean。 --&gt; &lt;bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"&gt; &lt;property name="basePackage" value="com.leopardsnow.ci.mapper" /&gt; &lt;/bean&gt; &lt;/beans&gt; </pre> <p> </p>
springboot+mybatis切换数据源问题
# 问题描述 springboot+mybatis想实现oracle和Mysql数据库切换,目前用 Mysql作为 主数据源时, 可以正常查询;用Oracle作为主数据源时,也可以正常查询;目前想实现,Mysql作为主数据源时,也可以切换到另外一个数据源。 # 相关代码如下 ## 创建数据源 ### 创建Mysql数据源 ``` @Bean(name = "dataSource") @Primary public ComboPooledDataSource createDataSource() throws PropertyVetoException { ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource(); comboPooledDataSource.setDriverClass(jdbcDriver); comboPooledDataSource.setJdbcUrl(jdbcUrl); comboPooledDataSource.setUser(jdbcUsername); comboPooledDataSource.setPassword(jdbcPassword); //连接关闭不自动提交 comboPooledDataSource.setAutoCommitOnClose(false); return comboPooledDataSource; } @Bean(name="sqlSessionFactory") @Primary public SqlSessionFactoryBean createSqlSessionFactoryBean(@Qualifier("dataSource") DataSource dataSource) throws IOException { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(mybatisConfigFilePath)); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); String packageSearchPath = PathMatchingResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + mapperPath; sqlSessionFactoryBean.setMapperLocations(resolver.getResources(packageSearchPath)); sqlSessionFactoryBean.setDataSource(dataSource); sqlSessionFactoryBean.setTypeAliasesPackage(entityPackage); return sqlSessionFactoryBean; } ``` ### 创建oracle数据源 ``` @Bean(name="oracleDataSource") public ComboPooledDataSource createOracleDataSource() throws PropertyVetoException { ComboPooledDataSource comboPooledOracleDataSource = new ComboPooledDataSource(); comboPooledOracleDataSource.setDriverClass(oracleJdbcDriver); comboPooledOracleDataSource.setJdbcUrl(oracleJdbcUrl); comboPooledOracleDataSource.setUser(oracleJdbcUser); comboPooledOracleDataSource.setPassword(oracleJdbcPassword); comboPooledOracleDataSource.setAutoCommitOnClose(false); return comboPooledOracleDataSource; } @Bean(name="oracleSqlSessionFactory") public SqlSessionFactoryBean createSqlSessionFactoryBean(@Qualifier("oracleDataSource") DataSource oracleDataSource) throws IOException { SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean(); sqlSessionFactoryBean.setConfigLocation(new ClassPathResource(mybatisConfigFilePath)); PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); String packageSearchPath = PathMatchingResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + oracleMapperPath; sqlSessionFactoryBean.setMapperLocations(resolver.getResources(packageSearchPath)); sqlSessionFactoryBean.setDataSource(oracleDataSource); sqlSessionFactoryBean.setTypeAliasesPackage(entityPackage); return sqlSessionFactoryBean; } ``` ## 事物管理代码段 ``` @Autowired @Qualifier("dataSource") private DataSource dataSource; @Autowired @Qualifier("oracleDataSource") private DataSource oracleDataSource; @Bean(name="localMysql") public PlatformTransactionManager localMysqlManager(){ return new DataSourceTransactionManager(dataSource); } @Bean(name="localOracle") public PlatformTransactionManager oracleManager(){ return new DataSourceTransactionManager(oracleDataSource); } ``` ## 切换数据源代码段 ``` @Override @Transactional(value = "localOracle") public List<Map> listOracle() { return helloOracleDao.listHello(); } ``` # 问题 感觉数据源创建什么的都没问题,但是最后一步切换不生效,不知道什么问题,还请大神赐教
atomikos-UserTransactionManager找不到
spring mvc+atomikos+mybatis中项目启动时提示:错误 org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.atomikos.icatch.jta.UserTransactionImp] for bean with name 'atomikosUserTransaction' defined in class path resource [spring-mybatis.xml]; nested exception is java.lang.ClassNotFoundException: com.atomikos.icatch.jta.UserTransactionImp 以及java.lang.ClassNotFoundException: com.atomikos.icatch.jta.UserTransactionManager。 在transactions-jta.jar中我找到了 com.atomikos.icatch.jta.UserTransactionManager和 com.atomikos.icatch.jta.UserTransactionImp并且我引入了该jar, 但是依然报错,我把需要的所有jar包都在pom里声明了一下,如下图: ![图片说明](https://img-ask.csdn.net/upload/201512/02/1449066378_94820.jpg) 但是依然是undefined,实在不知是何原因 下图是配置文件中的事物配置 ![图片说明](https://img-ask.csdn.net/upload/201512/02/1449066098_607580.jpg)
html文件能加载,但是css,js文件加载失败。
问题是:我直接在本地文件中找到那个html文件,用浏览器打开没有半点问题,但是我用 tomcat容器部署后,在浏览器地址栏用localhost:8080+应用名什么的访问的时候, 浏览器中只加载了那个html文件中的一些字、div什么的,外部导入的css,js文件都不显示,打开浏览器的控制台上各种资源找不到,404,用了ssm框架。html文件等是网上下的模板。 求大神指导!!! 贴代码贴代码:web.xml的配置 <welcome-file-list> <welcome-file>index.shop</welcome-file> </welcome-file-list> <servlet> <servlet-name>shop</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/spring-*.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>shop</servlet-name> <url-pattern>*.shop</url-pattern> </servlet-mapping> </web-app> spring配置文件: <!-- 配置数据库连接参数及连接池 --> <bean id="dbcp" class="org.apache.commons.dbcp.BasicDataSource"> <property name="username" value="dbsnmp"/> <property name="password" value="Jindex"/> <property name="driverClassName" value="oracle.jdbc.OracleDriver"></property> <property name="url" value="jdbc:oracle:thin:@localhost:1521:Jindex"></property> </bean> <!-- 配置SqlSessionFactory处理类 --> <bean id="ssf" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dbcp"></property> <property name="mapperLocations" value="classpath:myBatis/*.xml"/> </bean> <!-- 配置mapper扫描 --> <bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.chanct.shop.personal.dao"></property> </bean> <!-- 配置事物管理器,使申明式事务管理生效 --> <tx:annotation-driven transaction-manager="txManager"/> <!-- txManager 是一个Bean组件 --> <!-- MyBatis使用spring提供的DataSourceTransactionManager 使用DataSourceTransactionManager 必须设置属性dataSource --> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dbcp"></property> </bean> 还有一个spring的配置文件里面是组件扫描,mvc注解扫描和视图解析器
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小人工智障。 思路可以运用在不同地方,主要介绍的是思路。
Linux(服务器编程):15---两种高效的事件处理模式(reactor模式、proactor模式)
前言 同步I/O模型通常用于实现Reactor模式 异步I/O模型则用于实现Proactor模式 最后我们会使用同步I/O方式模拟出Proactor模式 一、Reactor模式 Reactor模式特点 它要求主线程(I/O处理单元)只负责监听文件描述符上是否有事件发生,有的话就立即将时间通知工作线程(逻辑单元)。除此之外,主线程不做任何其他实质性的工作 读写数据,接受新的连接,以及处...
为什么要学数据结构?
一、前言 在可视化化程序设计的今天,借助于集成开发环境可以很快地生成程序,程序设计不再是计算机专业人员的专利。很多人认为,只要掌握几种开发工具就可以成为编程高手,其实,这是一种误解。要想成为一个专业的开发人员,至少需要以下三个条件: 1) 能够熟练地选择和设计各种数据结构和算法 2) 至少要能够熟练地掌握一门程序设计语言 3) 熟知所涉及的相关应用领域的知识 其中,后两个条件比较容易实现,而第一个...
C语言魔塔游戏
很早就很想写这个,今天终于写完了。 游戏截图: 编译环境: VS2017 游戏需要一些图片,如果有想要的或者对游戏有什么看法的可以加我的QQ 2985486630 讨论,如果暂时没有回应,可以在博客下方留言,到时候我会看到。 下面我来介绍一下游戏的主要功能和实现方式 首先是玩家的定义,使用结构体,这个名字是可以自己改变的 struct gamerole { char n
进程通信方式总结与盘点
​ 进程通信是指进程之间的信息交换。这里需要和进程同步做一下区分,进程同步控制多个进程按一定顺序执行,进程通信是一种手段,而进程同步是目标。从某方面来讲,进程通信可以解决进程同步问题。 ​ 首先回顾下我们前面博文中讲到的信号量机制,为了实现进程的互斥与同步,需要在进程间交换一定的信息,因此信号量机制也可以被归为进程通信的一种方式,但是也被称为低级进程通信,主要原因为: 效率低:一次只可操作少量的...
究竟你适不适合买Mac?
我清晰的记得,刚买的macbook pro回到家,开机后第一件事情,就是上了淘宝网,花了500元钱,找了一个上门维修电脑的师傅,上门给我装了一个windows系统。。。。。。 表砍我。。。 当时买mac的初衷,只是想要个固态硬盘的笔记本,用来运行一些复杂的扑克软件。而看了当时所有的SSD笔记本后,最终决定,还是买个好(xiong)看(da)的。 已经有好几个朋友问我mba怎么样了,所以今天尽量客观
听说了吗?阿里双11作战室竟1根网线都没有
双11不光是购物狂欢节,更是对技术的一次“大考”,对于阿里巴巴企业内部运营的基础保障技术而言,亦是如此。 回溯双11历史,这背后也经历过“小米加步枪”的阶段:作战室从随处是网线,交换机放地上的“一地狼藉”;到如今媲美5G的wifi网速,到现场却看不到一根网线;从当年使用商用AP(无线路由器),让光明顶双11当天断网一分钟,到全部使用阿里自研AP……阿里巴巴企业智能事业部工程师们提供的基础保障...
在阿里,40岁的奋斗姿势
在阿里,40岁的奋斗姿势 在阿里,什么样的年纪可以称为老呢?35岁? 在云网络,有这样一群人,他们的平均年龄接近40,却刚刚开辟职业生涯的第二战场。 他们的奋斗姿势是什么样的呢? 洛神赋 “翩若惊鸿,婉若游龙。荣曜秋菊,华茂春松。髣髴兮若轻云之蔽月,飘飖兮若流风之回雪。远而望之,皎若太阳升朝霞;迫而察之,灼若芙蕖出渌波。” 爱洛神,爱阿里云 2018年,阿里云网络产品部门启动洛神2.0升...
关于研发效能提升的思考
研发效能提升是最近比较热门的一个话题,本人根据这几年的工作心得,做了一些思考总结,由于个人深度有限,暂且抛转引入。 三要素 任何生产力的提升都离不开这三个因素:人、流程和工具,少了其中任何一个因素都无法实现。 人,即思想,也就是古人说的“道”,道不同不相为谋,是制高点,也是高层建筑的基石。 流程,即方法,也是古人说的“法”。研发效能的提升,也就是要提高投入产出比,既要增加产出,也要减...
Python爬虫爬取淘宝,京东商品信息
小编是一个理科生,不善长说一些废话。简单介绍下原理然后直接上代码。 使用的工具(Python+pycharm2019.3+selenium+xpath+chromedriver)其中要使用pycharm也可以私聊我selenium是一个框架可以通过pip下载 pip install selenium -i https://pypi.tuna.tsinghua.edu.cn/simple/ 
阿里程序员写了一个新手都写不出的低级bug,被骂惨了。
这种新手都不会范的错,居然被一个工作好几年的小伙子写出来,差点被当场开除了。
Java工作4年来应聘要16K最后没要,细节如下。。。
前奏: 今天2B哥和大家分享一位前几天面试的一位应聘者,工作4年26岁,统招本科。 以下就是他的简历和面试情况。 基本情况: 专业技能: 1、&nbsp;熟悉Sping了解SpringMVC、SpringBoot、Mybatis等框架、了解SpringCloud微服务 2、&nbsp;熟悉常用项目管理工具:SVN、GIT、MAVEN、Jenkins 3、&nbsp;熟悉Nginx、tomca
2020年,冯唐49岁:我给20、30岁IT职场年轻人的建议
点击“技术领导力”关注∆  每天早上8:30推送 作者| Mr.K   编辑| Emma 来源| 技术领导力(ID:jishulingdaoli) 前天的推文《冯唐:职场人35岁以后,方法论比经验重要》,收到了不少读者的反馈,觉得挺受启发。其实,冯唐写了不少关于职场方面的文章,都挺不错的。可惜大家只记住了“春风十里不如你”、“如何避免成为油腻腻的中年人”等不那么正经的文章。 本文整理了冯
程序员该看的几部电影
##1、骇客帝国(1999) 概念:在线/离线,递归,循环,矩阵等 剧情简介: 不久的将来,网络黑客尼奥对这个看似正常的现实世界产生了怀疑。 他结识了黑客崔妮蒂,并见到了黑客组织的首领墨菲斯。 墨菲斯告诉他,现实世界其实是由一个名叫“母体”的计算机人工智能系统控制,人们就像他们饲养的动物,没有自由和思想,而尼奥就是能够拯救人类的救世主。 可是,救赎之路从来都不会一帆风顺,到底哪里才是真实的世界?
入职阿里5年,他如何破解“技术债”?
简介: 作者 | 都铎 作为一名技术人,你常常会听到这样的话: “先快速上线” “没时间改” “再缓一缓吧” “以后再解决” “先用临时方案处理” …… 当你埋下的坑越来越多,不知道哪天哪位同学就会踩上一颗雷。特别赞同“人最大的恐惧就是未知,当技术债可说不可见的时候,才是最让人不想解决的时候。” 作为一个程序员,我们反对复制粘贴,但是我们经常会见到相似的代码,相同的二方包,甚至整个代码...
Python绘图,圣诞树,花,爱心 | Turtle篇
每周每日,分享Python实战代码,入门资料,进阶资料,基础语法,爬虫,数据分析,web网站,机器学习,深度学习等等。 公众号回复【进群】沟通交流吧,QQ扫码进群学习吧 微信群 QQ群 1.画圣诞树 import turtle screen = turtle.Screen() screen.setup(800,600) circle = turtle.Turtle()...
作为一个程序员,CPU的这些硬核知识你必须会!
CPU对每个程序员来说,是个既熟悉又陌生的东西? 如果你只知道CPU是中央处理器的话,那可能对你并没有什么用,那么作为程序员的我们,必须要搞懂的就是CPU这家伙是如何运行的,尤其要搞懂它里面的寄存器是怎么一回事,因为这将让你从底层明白程序的运行机制。 随我一起,来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说,我们首先就要搞明白它是怎么回事,也就是它的内部构造,当然,CPU那么牛的一个东
破14亿,Python分析我国存在哪些人口危机!
2020年1月17日,国家统计局发布了2019年国民经济报告,报告中指出我国人口突破14亿。 猪哥的朋友圈被14亿人口刷屏,但是很多人并没有看到我国复杂的人口问题:老龄化、男女比例失衡、生育率下降、人口红利下降等。 今天我们就来分析一下我们国家的人口数据吧! 一、背景 1.人口突破14亿 2020年1月17日,国家统计局发布了 2019年国民经济报告 ,报告中指出:年末中国大陆总人口(包括31个
在家远程办公效率低?那你一定要收好这个「在家办公」神器!
相信大家都已经收到国务院延长春节假期的消息,接下来,在家远程办公可能将会持续一段时间。 但是问题来了。远程办公不是人在电脑前就当坐班了,相反,对于沟通效率,文件协作,以及信息安全都有着极高的要求。有着非常多的挑战,比如: 1在异地互相不见面的会议上,如何提高沟通效率? 2文件之间的来往反馈如何做到及时性?如何保证信息安全? 3如何规划安排每天工作,以及如何进行成果验收? ......
作为一个程序员,内存和磁盘的这些事情,你不得不知道啊!!!
截止目前,我已经分享了如下几篇文章: 一个程序在计算机中是如何运行的?超级干货!!! 作为一个程序员,CPU的这些硬核知识你必须会! 作为一个程序员,内存的这些硬核知识你必须懂! 这些知识可以说是我们之前都不太重视的基础知识,可能大家在上大学的时候都学习过了,但是嘞,当时由于老师讲解的没那么有趣,又加上这些知识本身就比较枯燥,所以嘞,大家当初几乎等于没学。 再说啦,学习这些,也看不出来有什么用啊!
2020年的1月,我辞掉了我的第一份工作
其实,这篇文章,我应该早点写的,毕竟现在已经2月份了。不过一些其它原因,或者是我的惰性、还有一些迷茫的念头,让自己迟迟没有试着写一点东西,记录下,或者说是总结下自己前3年的工作上的经历、学习的过程。 我自己知道的,在写自己的博客方面,我的文笔很一般,非技术类的文章不想去写;另外我又是一个还比较热衷于技术的人,而平常复杂一点的东西,如果想写文章写的清楚点,是需要足够...
别低估自己的直觉,也别高估自己的智商
所有群全部吵翻天,朋友圈全部沦陷,公众号疯狂转发。这两周没怎么发原创,只发新闻,可能有人注意到了。我不是懒,是文章写了却没发,因为大家的关注力始终在这次的疫情上面,发了也没人看。当然,我...
Java坑人面试题系列: 包装类(中级难度)
Java Magazine上面有一个专门坑人的面试题系列: https://blogs.oracle.com/javamagazine/quiz-2。 这些问题的设计宗旨,主要是测试面试者对Java语言的了解程度,而不是为了用弯弯绕绕的手段把面试者搞蒙。 如果你看过往期的问题,就会发现每一个都不简单。 这些试题模拟了认证考试中的一些难题。 而 “中级(intermediate)” 和 “高级(ad
深度学习入门笔记(十八):卷积神经网络(一)
欢迎关注WX公众号:【程序员管小亮】 专栏——深度学习入门笔记 声明 1)该文章整理自网上的大牛和机器学习专家无私奉献的资料,具体引用的资料请看参考文献。 2)本文仅供学术交流,非商用。所以每一部分具体的参考资料并没有详细对应。如果某部分不小心侵犯了大家的利益,还望海涵,并联系博主删除。 3)博主才疏学浅,文中如有不当之处,请各位指出,共同进步,谢谢。 4)此属于第一版本,若有错误,还需继续修正与...
这个世界上人真的分三六九等,你信吗?
偶然间,在知乎上看到一个问题 一时间,勾起了我深深的回忆。 以前在厂里打过两次工,做过家教,干过辅导班,做过中介。零下几度的晚上,贴过广告,满脸、满手地长冻疮。 再回首那段岁月,虽然苦,但让我学会了坚持和忍耐。让我明白了,在这个世界上,无论环境多么的恶劣,只要心存希望,星星之火,亦可燎原。 下文是原回答,希望能对你能有所启发。 如果我说,这个世界上人真的分三六九等,...
节后首个工作日,企业们集体开晨会让钉钉挂了
By 超神经场景描述:昨天 2 月 3 日,是大部分城市号召远程工作的第一天,全国有接近 2 亿人在家开始远程办公,钉钉上也有超过 1000 万家企业活跃起来。关键词:十一出行 人脸...
Java基础知识点梳理
Java基础知识点梳理 摘要: 虽然已经在实际工作中经常与java打交道,但是一直没系统地对java这门语言进行梳理和总结,掌握的知识也比较零散。恰好利用这段时间重新认识下java,并对一些常见的语法和知识点做个总结与回顾,一方面为了加深印象,方便后面查阅,一方面为了学好java打下基础。 Java简介 java语言于1995年正式推出,最开始被命名为Oak语言,由James Gosling(詹姆
2020年全新Java学习路线图,含配套视频,学完即为中级Java程序员!!
新的一年来临,突如其来的疫情打破了平静的生活! 在家的你是否很无聊,如果无聊就来学习吧! 世上只有一种投资只赚不赔,那就是学习!!! 传智播客于2020年升级了Java学习线路图,硬核升级,免费放送! 学完你就是中级程序员,能更快一步找到工作! 一、Java基础 JavaSE基础是Java中级程序员的起点,是帮助你从小白到懂得编程的必经之路。 在Java基础板块中有6个子模块的学
B 站上有哪些很好的学习资源?
哇说起B站,在小九眼里就是宝藏般的存在,放年假宅在家时一天刷6、7个小时不在话下,更别提今年的跨年晚会,我简直是跪着看完的!! 最早大家聚在在B站是为了追番,再后来我在上面刷欧美新歌和漂亮小姐姐的舞蹈视频,最近两年我和周围的朋友们已经把B站当作学习教室了,而且学习成本还免费,真是个励志的好平台ヽ(.◕ฺˇд ˇ◕ฺ;)ノ 下面我们就来盘点一下B站上优质的学习资源: 综合类 Oeasy: 综合
你也能看懂的:蒙特卡罗方法
蒙特卡罗方法,也称统计模拟方法,是1940年代中期由于科学技术的发展和电子计算机的发明,而提出的一种以概率统计理论为指导的数值计算方法。是指使用随机数(或更常见的伪随机数)来解决很多计算问题的方法 蒙特卡罗方法可以粗略地分成两类:一类是所求解的问题本身具有内在的随机性,借助计算机的运算能力可以直接模拟这种随机的过程。另一种类型是所求解问题可以转化为某种随机分布的特征数,比如随机事件出现的概率,或...
相关热词 c#导入fbx c#中屏蔽键盘某个键 c#正态概率密度 c#和数据库登陆界面设计 c# 高斯消去法 c# codedom c#读取cad文件文本 c# 控制全局鼠标移动 c# temp 目录 bytes初始化 c#
立即提问