Spring @Transactional annotations ignored

前端 未结 3 1153
野趣味
野趣味 2020-12-05 21:52

My @Transactionnal annotations seems to be ignored. I have no errors on the initialization of the Spring container. It looks like my method has not been proxied by Spring TX

3条回答
  •  一整个雨季
    2020-12-05 22:16

    You need to define an interface for the @Transactional annotations to work:

    public interface ApplicationsService {
        public void createApplication(Application application);
    }
    

    And the concrete class:

    @Service
    public class ApplicationsServiceImpl {
        @Transactional
        public void createApplication(Application application) {
            // ...
        }
    }
    

    Alternatively, per Kevin Welker's comment, if don't want an interface (though you probably should write an interface), you can configure use proxy-target-class:

    
    

    edit

    The message from your SQLException is:

    Field 'status' doesn't have a default value
    

    So maybe you're passing in null where you should be providing a value? Alternatively, check this post for some weirdness associated with this error.

提交回复
热议问题