print all data in paginated table/grid

direct Tabular data display Recently our project has a page need to show tabular data from 30-6000 rows with 3-4 columns. At first, I thought this is pretty reasonable data to show in one page so I just throw the data into a ng-repeat table with my own implementation of filtering/sorting which is pretty straightforward in…

Spring nested @Transactional rollback only

Recently we get some odd xxx Thread got an uncaught exception in Nagios alters. and the corresponding exception in log is : Turns out the reason is we have a nested method also marked @Transactional and some exception happened inside which causes Spring marked it as RollBackonly in the thread local TransactionStatus. So the possible solution is:…

logback spring boot rolling 配置

日志的配置 Spring Boot支持各种日志工具, 最常用的是Logback. 我们可以对日志进行配置, 由于日志是在ApplicationContext创建之前初始化的, 所以对日志的配置不能通过在@Configuration配置类上使用@PropertySources注解加载进来. 可以使用系统变量或者外部配置application.properties来加载. 配置文件中可以指定这些属性: logging.config=: 配置文件的位置, 比如:classpath:logback.xml(logback的配置文件) logging.file=: 日志文件名, 如:myapp.log, 输出日志到当前目录的myapp.log文件 logging.path=: 日志文件位置, 如:/var/log, 输出日志到/var/log/spring.log文件 logging.level.*=: 日志等级, 如:logging.level.org.springframework=DEBUG logging.pattern.console=: 输出到console的日志格式, 只有logback有效 logging.pattern.file=: 输出到文件的日志格式, 只有logback有效 logging.pattern.level=: 日志级别的格式, 默认是%5p. 只有logback有效 logging.exception-conversion-word=%wEx: log异常时使用哪个格式转换器(base.xml中定义了三个conversionRule) logging.register-shutdown-hook=false # Register a shutdown hook for the logging system when it is initialized(没用过) 上面这些属性配置, 一般写在application.properties中, 这样会被加载到Spring Environment中, 为了方便其他地方使用, Spring…

Spring componentscan custom annotation

Everyone seems to think annotations are cool and want to use them now days. A lot has been written about the pros and cons of using annotations and personally I think they should be used with caution. Mixing annotation domains to a point of total confusion, spreading configuration related meta-data across large code bases to…

Apache Camel notes

Apache Camel 2.15  Spring 4 Example Some other official examples : 1 , 2

spring annotation inheritance

@Autowired/@Inject (method) When you use @Inherited on a class annotation, this means that when that annotation is queried on a non-annotated subclass, the Java will look for it in the superclass. When you use @Inherited on a method annotation, this means that when that annotation is queried on a non-annotated method overridden in subclass, Java…

hibernate entitymanager spring BeanDefinitionStoreException FactoryConfigurationError DocumentBuilderFactory cannot be found

When we try to upgrade spring jpa/hibernate from 3 to 4. One of our standalone jar using spring has error when loading application context: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring/application-context-xxx.xml]; nested exception is javax.xml.parsers.FactoryConfigurationError: Provider for javax.xml.parsers.DocumentBuilderFactory cannot be found   After searching around, it turns out the hibernate-entitymanager 4.3.11 has a…

spring IoC life cycle

Spring IoC Initialization Life-cycle This is briefly enumerated: 1. Read and parse the Bean definitions (either as XML, JavaConfig) 2. Process BeanFactoryPostProcessors 3. Construct bean by calling its constructor 4. Call setters, dependencies injected 5. Inject the required beans as defined by the *Aware Interfaces 6. Call postProcessBeforeIntialization 7. Call the initializaion callbacks.(like InitializingBean’s afterPropertiesSet…

How does Spring @Transactional Really Work?

In this post we will do a deep dive into Spring transaction management. We will go over on how does @Transactional really works under the hood. Other upcoming posts will include: how to use features like propagation and isolation what are the main pitfalls and how to avoid them Database For a db transaction, it…

Spring proxy jdk vs cglib

Simple version: Aspectj static weaving: do the aop at compile time using Aspectj’s own compiler: ajc. JDK Proxy: when class implements some interface. The proxy will implement every interface. It can NOT be cast to the original target class because it’s simply a dynamic proxy that happens to implement the same interface(s) as the target CGLIB:…

BeanPostProcessor vs BeanFactoryPostProcessor

BeanFactoryPostProcessors affect BeanDefinition objects because they are run right after your configuration is read in. There are no bean instances created yet. So it can’t do anything to your objects instances yet. For Example the PropertyPlaceholderConfigurer is a BeanFactoryPostProcessor, which looks through the BeanDefinition objects and replaces any ${property.name} with the actual value of property.name…