Browse Source

优化配置

zhouhao 8 years ago
parent
commit
a3bee0b578

+ 0 - 1
hsweb-web-bean/pom.xml

@@ -15,7 +15,6 @@
         <dependency>
             <groupId>org.hibernate</groupId>
             <artifactId>hibernate-validator</artifactId>
-            <optional>true</optional>
         </dependency>
         <dependency>
             <groupId>org.hsweb</groupId>

+ 0 - 6
hsweb-web-service/hsweb-web-service-simple/pom.xml

@@ -19,12 +19,6 @@
             <scope>test</scope>
         </dependency>
 
-        <dependency>
-            <groupId>org.hibernate</groupId>
-            <artifactId>hibernate-validator</artifactId>
-            <optional>true</optional>
-        </dependency>
-
         <dependency>
             <groupId>org.quartz-scheduler</groupId>
             <artifactId>quartz</artifactId>

+ 3 - 6
hsweb-web-service/hsweb-web-service-simple/src/main/java/org/hsweb/web/service/impl/HibernateValidatorAutoConfiguration.java

@@ -8,15 +8,12 @@ import javax.validation.Validation;
 import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
 
-/**
- * Created by zhouhao on 16-4-25.
- */
 @Configuration
-@ConditionalOnMissingBean(Validator.class)
 public class HibernateValidatorAutoConfiguration {
 
-    @Bean
-    public Validator getHibernateValidator() {
+    @Bean(name = "validator")
+    @ConditionalOnMissingBean(Validator.class)
+    public Validator validator() {
         ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
         Validator validator = factory.getValidator();
         return validator;

+ 0 - 68
hsweb-web-service/hsweb-web-service-simple/src/test/java/org/hsweb/web/service/impl/quartz/QuartzTests.java

@@ -1,68 +0,0 @@
-/*
- * Copyright 2015-2016 http://hsweb.me
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.hsweb.web.service.impl.quartz;
-
-import org.hsweb.web.service.impl.AbstractTestCase;
-import org.junit.Test;
-import org.quartz.*;
-import org.quartz.impl.StdSchedulerFactory;
-import org.quartz.spi.MutableTrigger;
-import org.springframework.context.ApplicationContext;
-import org.springframework.scheduling.quartz.SchedulerFactoryBean;
-import org.springframework.transaction.PlatformTransactionManager;
-
-import javax.annotation.Resource;
-import javax.sql.DataSource;
-
-public class QuartzTests extends AbstractTestCase {
-    @Resource
-    private ApplicationContext applicationContext;
-
-    @Resource
-    private DataSource dataSource;
-
-    @Resource
-    private PlatformTransactionManager platformTransactionManager;
-
-    @Test
-    public void testQuartz() throws Exception {
-        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
-        schedulerFactoryBean.setApplicationContext(applicationContext);
-        schedulerFactoryBean.setAutoStartup(true);
-        schedulerFactoryBean.setDataSource(dataSource);
-        schedulerFactoryBean.setTransactionManager(platformTransactionManager);
-        schedulerFactoryBean.setOverwriteExistingJobs(true);
-        schedulerFactoryBean.setSchedulerFactoryClass(StdSchedulerFactory.class);
-        schedulerFactoryBean.afterPropertiesSet();
-        schedulerFactoryBean.setBeanName("schedulerFactory");
-        Scheduler scheduler = schedulerFactoryBean.getObject();
-
-//        MutableTrigger trigger   = CronScheduleBuilder.cronSchedule("0/2 * * * * ?").build();
-//        scheduler.deleteJob(new JobKey("test"));
-//        trigger.setKey(new TriggerKey("test"));
-//        scheduler.scheduleJob(JobBuilder.newJob(TestJob.class).withIdentity("test").build(), trigger);
-//        scheduler.deleteJob(new JobKey("test"));
-//        scheduler.scheduleJob(JobBuilder.newJob(TestJob.class).withIdentity("test").build(), trigger);
-        scheduler.resumeAll();
-        scheduler.start();
-
-//        schedulerFactoryBean.start();
-        Thread.sleep(60 * 1000);
-    }
-
-
-}

+ 0 - 33
hsweb-web-service/hsweb-web-service-simple/src/test/java/org/hsweb/web/service/impl/quartz/TestJob.java

@@ -1,33 +0,0 @@
-/*
- * Copyright 2015-2016 http://hsweb.me
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.hsweb.web.service.impl.quartz;
-
-import org.quartz.*;
-
-@DisallowConcurrentExecution
-public class TestJob implements Job {
-    @Override
-    public void execute(JobExecutionContext context) throws JobExecutionException {
-        System.out.println(context.getJobDetail());
-        try {
-            Thread.sleep(5000);
-            System.out.println(111);
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-        }
-    }
-}