spring mvc - Transaction rollback not work(I've already add @EnableTransactionManagement and @Transactional) -
@configuration @import({datasourceconfig.class}) @enabletransactionmanagement(proxytargetclass = true) @enableaspectjautoproxy(proxytargetclass = true) @componentscan(basepackages = "**.service") public class rootconfig {} @bean @dependson(value = "datasource") public datasourcetransactionmanager transactionmanager() { return new datasourcetransactionmanager(datasource()); }
the config above,and service code below
@override @transactional public int rechargechannel(int channelid) { chargerecord chargerecord = new chargerecord(); chargerecord.setchannelid(channelid); chargerecord.setcreatetime(new date()); chargerecordmapper.insertselective(chargerecord); int = 4/0; return result; }
problems: 1.can' t rollback success; 2.why datasource init twice.
Comments
Post a Comment