弹幕下载

master
10295 7 years ago
parent 2e7f33b451
commit a16702d659
  1. 14
      web/src/main/java/web/config/SpringConfig.java
  2. 5
      web/src/main/java/web/html/ElementId.java
  3. 6
      web/src/main/java/web/util/DynamicTimer.java
  4. 4
      web/src/test/java/Test.java

@ -1,20 +1,16 @@
package web.config;
import db.config.HibernateConfig;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.orm.hibernate5.support.OpenSessionInViewInterceptor;
import org.springframework.web.servlet.config.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* Created by reborn on 2017/7/28.
@ -25,8 +21,6 @@ import java.util.Map;
@ComponentScan({"web.controller","web.service","web.util"})
public class SpringConfig implements WebMvcConfigurer {
@Resource
private DefaultListableBeanFactory beanFactory;
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
@ -42,13 +36,11 @@ public class SpringConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
Map<String, HibernateTemplate> hibernateTemplateMap= HibernateConfig.get();
for(String key:hibernateTemplateMap.keySet()) {
HibernateConfig.get().forEach((key,hibernateTemplate)->{
OpenSessionInViewInterceptor interceptor = new OpenSessionInViewInterceptor();
interceptor.setSessionFactory(hibernateTemplateMap.get(key).getSessionFactory());
interceptor.setSessionFactory(hibernateTemplate.getSessionFactory());
registry.addWebRequestInterceptor(interceptor);
}
});
}
@Override

@ -1,5 +1,6 @@
package web.html;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
@ -21,9 +22,7 @@ public enum ElementId {
public static Map<String,ElementId> getAll(){
Map<String,ElementId> map=new HashMap<>();
for(ElementId id:ElementId.values()){
map.put(id.name(),id);
}
EnumSet.allOf(ElementId.class).forEach(elementId -> map.put(elementId.name(),elementId));
return map;
}
}

@ -18,7 +18,6 @@ import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
import java.util.List;
/**
* Created by reborn on 2017/5/8.
@ -34,10 +33,7 @@ public class DynamicTimer extends ScheduledTaskRegistrar {
@PostConstruct
public void init(){
List<ScheduledTaskEntity> taskList=hibernateTemplate.loadAll(ScheduledTaskEntity.class);
for(ScheduledTaskEntity task:taskList){
addTriggerTask(task);
}
hibernateTemplate.loadAll(ScheduledTaskEntity.class).forEach(this::addTriggerTask);
}
public void addTriggerTask(ScheduledTaskEntity scheduledTaskEntity) {

@ -1,5 +1,3 @@
import db.annotation.BiliBili;
import db.util.ClassScaner;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -7,6 +5,6 @@ public class Test {
private static Logger log = LogManager.getLogger();
public static void main(String[] args) {
ClassScaner.scan("db.model",BiliBili.class).forEach(aClass -> System.out.println(aClass));
}
}

Loading…
Cancel
Save