Maven依赖排除 禁止依赖传递 取消依赖的方法
本教程目录:
- 自定义线程池
- 配置spring默认的线程池
1. 自定义线程池
1.1 修改application.properties
task.pool.corePoolSize=
task.pool.maxPoolSize=
task.pool.keepAliveSeconds=
task.pool.queueCapacity=
1.2 线程池配置属性类TaskThreadPoolConfig .java
import org.springframework.boot.context.properties.ConfigurationProperties; /**
* 线程池配置属性类
*/
@ConfigurationProperties(prefix = "task.pool")
public class TaskThreadPoolConfig {
private int corePoolSize; private int maxPoolSize; private int keepAliveSeconds; private int queueCapacity;
//...getter and setter methods...
}
1.3 创建线程池 TaskExecutePool .java
/**
* 创建线程池
*/
@Configuration
@EnableAsync
public class TaskExecutePool {
@Autowired
private TaskThreadPoolConfig config; @Bean
public Executor myTaskAsyncPool() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//核心线程池大小
executor.setCorePoolSize(config.getCorePoolSize());
//最大线程数
executor.setMaxPoolSize(config.getMaxPoolSize());
//队列容量
executor.setQueueCapacity(config.getQueueCapacity());
//活跃时间
executor.setKeepAliveSeconds(config.getKeepAliveSeconds());
//线程名字前缀
executor.setThreadNamePrefix("MyExecutor-"); // setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务
// CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());executor.setWaitForTasksToCompleteOnShutdown(
true
);
executor.setAwaitTerminationSeconds(
60
);
executor.initialize();
return executor;
}
}
上面我们通过使用ThreadPoolTaskExecutor
创建了一个线程池,同时设置了以下这些参数:
- 核心线程数20:线程池创建时候初始化的线程数
- 最大线程数40:线程池最大的线程数,只有在缓冲队列满了之后才会申请超过核心线程数的线程
- 缓冲队列50:用来缓冲执行任务的队列
- 允许线程的空闲时间300秒:当超过了核心线程出之外的线程在空闲时间到达之后会被销毁
- 线程池名的前缀:设置好了之后可以方便我们定位处理任务所在的线程池
- 线程池对拒绝任务的处理策略:这里采用了
CallerRunsPolicy
策略,当线程池没有处理能力的时候,该策略会直接在 execute 方法的调用线程中运行被拒绝的任务;如果执行程序已关闭,则会丢弃该任务
(ThreadPoolExecutor.AbortPolicy 丢弃任务并抛出RejectedExecutionException异常(默认)。
ThreadPoolExecutor.DiscardPolic 丢弃任务,但是不抛出异常。
ThreadPoolExecutor.DiscardOldestPolicy 丢弃队列最前面的任务,然后重新尝试执行任务
ThreadPoolExecutor.CallerRunsPolic 由调用线程处理该任务)
说明:setWaitForTasksToCompleteOnShutdown(true)
该方法就是这里的关键,用来设置线程池关闭的时候等待所有任务都完成再继续销毁其他的Bean,这样这些异步任务的销毁就会先于Redis线程池的销毁。同时,这里还设置了setAwaitTerminationSeconds(60),该方法用来设置线程池中任务的等待时间,如果超过这个时候还没有销毁就强制销毁,以确保应用最后能够被关闭,而不是阻塞住。
1.4 创建线程任务
@Component
public class AsyncTask {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); @Async("myTaskAsyncPool") //myTaskAsynPool即配置线程池的方法名,此处如果不写自定义线程池的方法名,会使用默认的线程池
public void doTask1(int i) throws InterruptedException{
logger.info("Task"+i+" started.");
}
}
1.5 修改启动类
给启动类添加注解
@EnableAsync
@EnableConfigurationProperties({TaskThreadPoolConfig.class} ) // 开启配置属性支持
1.6 测试
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private AsyncTask asyncTask; @Test
public void AsyncTaskTest() throws InterruptedException, ExecutionException { for (int i = 0; i < 100; i++) {
asyncTask.doTask1(i);
}
logger.info("All tasks finished.");
}
2. 配置spring/springboot默认的异步线程池
因为上面的那个线程池使用时候总要加注解@Async("myTaskAsyncPool")
,(会影响业务系统中的多处修改)
如果我们想使用默认的线程池,即使用异步线程池时还是使用@Async的注解。但是只是想修改默认线程池的配置,将默认的异步线程池的参数可配置化,方便系统的调优。那怎么做了,此时我们需要实现AsyncConfigurer类,示例代码如下:
public interface AsyncConfigurer { Executor getAsyncExecutor(); AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler(); }
说明:
Executor : 处理异步方法调用时要使用的实例,
AsyncUncaughtExceptionHandler :在使用void
返回类型的异步方法执行期间抛出异常时要使用的实例。
2.1 获取属性配置类
这个和上面的TaskThreadPoolConfig类相同,这里不重复
2.2 NativeAsyncTaskExecutePool.java 装配线程池
/**
* 原生(Spring)异步任务线程池装配类
*/
@Slf4j
@Configuration
public class NativeAsyncTaskExecutePool implements AsyncConfigurer { //注入配置类
@Autowired
TaskThreadPoolConfig config; @Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//核心线程池大小
executor.setCorePoolSize(config.getCorePoolSize());
//最大线程数
executor.setMaxPoolSize(config.getMaxPoolSize());
//队列容量
executor.setQueueCapacity(config.getQueueCapacity());
//活跃时间
executor.setKeepAliveSeconds(config.getKeepAliveSeconds());
//线程名字前缀
executor.setThreadNamePrefix("MyExecutor-"); // setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务
// CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize();
return executor;
} /**
* 异步任务中异常处理
* @return
*/
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return new AsyncUncaughtExceptionHandler() { @Override
public void handleUncaughtException(Throwable arg0, Method arg1, Object... arg2) {
log.error("=========================="+arg0.getMessage()+"=======================", arg0);
log.error("exception method:"+arg1.getName());
}
};
}
}
2.3 线程任务类AsyncTask .java
@Component
public class AsyncTask {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); @Async
public void doTask2(int i) throws InterruptedException{
logger.info("Task2-Native"+i+" started.");
}
}
2.4 测试
@Test
public void AsyncTaskNativeTest() throws InterruptedException, ExecutionException { for (int i = 0; i < 100; i++) {
asyncTask.doTask2(i);
} logger.info("All tasks finished.");
}
结果:
2018-03-25 21:23:07.655 INFO 4668 --- [ MyExecutor-8] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native6 started.
2018-03-25 21:23:07.655 INFO 4668 --- [ MyExecutor-3] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native1 started.
2018-03-25 21:23:07.655 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native7 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native21 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native22 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native23 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native24 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native25 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native26 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native27 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native28 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native29 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native30 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native31 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native32 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native33 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native34 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native35 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native36 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native37 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native38 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native39 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native40 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native41 started.
2018-03-25 21:23:07.657 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native42 started.
2018-03-25 21:23:07.657 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native43 started.
2018-03-25 21:23:07.657 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native44 started.
2018-03-25 21:23:07.657 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native45 started.
2018-03-25 21:23:07.657 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native46 started.
2018-03-25 21:23:07.658 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native47 started.
2018-03-25 21:23:07.655 INFO 4668 --- [ MyExecutor-7] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native5 started.
2018-03-25 21:23:07.658 INFO 4668 --- [ MyExecutor-7] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native49 started.
2018-03-25 21:23:07.658 INFO 4668 --- [ MyExecutor-7] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native50 started.
2018-03-25 21:23:07.658 INFO 4668 --- [ MyExecutor-11] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native9 started.
2018-03-25 21:23:07.655 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native4 started.
2018-03-25 21:23:07.659 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native53 started.
2018-03-25 21:23:07.659 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native54 started.
2018-03-25 21:23:07.659 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native55 started.
2018-03-25 21:23:07.659 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native56 started.
2018-03-25 21:23:07.659 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native57 started.
2018-03-25 21:23:07.659 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native58 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native59 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native60 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native61 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native62 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native63 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native64 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native65 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native66 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native67 started.
2018-03-25 21:23:07.660 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native68 started.
2018-03-25 21:23:07.655 INFO 4668 --- [ MyExecutor-5] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native3 started.
2018-03-25 21:23:07.655 INFO 4668 --- [ MyExecutor-4] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native2 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-8] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native19 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-2] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native0 started.
2018-03-25 21:23:07.656 INFO 4668 --- [ MyExecutor-3] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native20 started.
2018-03-25 21:23:07.657 INFO 4668 --- [ MyExecutor-10] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native8 started.
2018-03-25 21:23:07.658 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native48 started.
2018-03-25 21:23:07.658 INFO 4668 --- [ MyExecutor-7] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native51 started.
2018-03-25 21:23:07.658 INFO 4668 --- [ MyExecutor-11] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native52 started.
2018-03-25 21:23:07.658 INFO 4668 --- [ MyExecutor-12] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native10 started.
2018-03-25 21:23:07.661 INFO 4668 --- [ MyExecutor-13] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native11 started.
2018-03-25 21:23:07.662 INFO 4668 --- [ MyExecutor-14] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native12 started.
2018-03-25 21:23:07.662 INFO 4668 --- [ MyExecutor-15] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native13 started.
2018-03-25 21:23:07.663 INFO 4668 --- [ MyExecutor-16] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native14 started.
2018-03-25 21:23:07.663 INFO 4668 --- [ MyExecutor-17] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native15 started.
2018-03-25 21:23:07.663 INFO 4668 --- [ MyExecutor-18] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native16 started.
2018-03-25 21:23:07.663 INFO 4668 --- [ MyExecutor-19] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native17 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-20] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native18 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-21] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native69 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ main] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native89 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-6] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native90 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-22] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native70 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-5] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native91 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-5] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native92 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-8] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native93 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-2] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native94 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-10] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native95 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-3] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native96 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-7] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native98 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-9] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native97 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ MyExecutor-11] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native99 started.
2018-03-25 21:23:07.664 INFO 4668 --- [ main] com.laojiao.securitydemo.ControllerTest : All tasks finished.
2018-03-25 21:23:07.666 INFO 4668 --- [ MyExecutor-23] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native71 started.
2018-03-25 21:23:07.667 INFO 4668 --- [ MyExecutor-24] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native72 started.
2018-03-25 21:23:07.667 INFO 4668 --- [ MyExecutor-25] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native73 started.
2018-03-25 21:23:07.669 INFO 4668 --- [ MyExecutor-26] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native74 started.
2018-03-25 21:23:07.669 INFO 4668 --- [ MyExecutor-27] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native75 started.
2018-03-25 21:23:07.673 INFO 4668 --- [ MyExecutor-28] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native76 started.
2018-03-25 21:23:07.674 INFO 4668 --- [ MyExecutor-29] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native77 started.
2018-03-25 21:23:07.674 INFO 4668 --- [ MyExecutor-30] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native78 started.
2018-03-25 21:23:07.676 INFO 4668 --- [ MyExecutor-31] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native79 started.
2018-03-25 21:23:07.677 INFO 4668 --- [ MyExecutor-32] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native80 started.
2018-03-25 21:23:07.677 INFO 4668 --- [ MyExecutor-33] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native81 started.
2018-03-25 21:23:07.677 INFO 4668 --- [ MyExecutor-34] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native82 started.
2018-03-25 21:23:07.678 INFO 4668 --- [ MyExecutor-35] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native83 started.
2018-03-25 21:23:07.679 INFO 4668 --- [ MyExecutor-36] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native84 started.
2018-03-25 21:23:07.679 INFO 4668 --- [ MyExecutor-37] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native85 started.
2018-03-25 21:23:07.679 INFO 4668 --- [ MyExecutor-38] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native86 started.
2018-03-25 21:23:07.680 INFO 4668 --- [ MyExecutor-39] c.l.securitydemo.mythreadpool.AsyncTask : Task2-Native87 started.
2018-03-25 21:23:07.680 INFO 4668 --- [ MyExecutor-
Maven依赖排除 禁止依赖传递 取消依赖的方法的更多相关文章
- 10.Maven依赖排除 禁止依赖传递 取消依赖的方法
转自:https://www.cnblogs.com/duanxz/p/6084494.html 大家都知道Maven的优点是依赖管理,特别是前期使用ANT的开发者都有很多感触.最近要开发一个java ...
- 说说maven依赖冲突,依赖调解,依赖传递和依赖范围
说maven依赖冲突之前需要先说说maven的 依赖传递. 依赖传递 当前项目引入了一个依赖,该依赖的依赖也会被引入项目.更加准确的说法是,maven会解析直接依赖的POM,将那些必要的间接依赖,以传 ...
- maven可选依赖(Optional Dependencies)和依赖排除(Dependency Exclusions)
我们知道,maven的依赖关系是有传递性的.如:A-->B,B-->C.但有时候,项目A可能不是必需依赖C,因此需要在项目A中排除对A的依赖.在maven的依赖管理中,有两种方式可以对依赖 ...
- Maven依赖传递、依赖传递排除、依赖冲突
转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6628429.html 一:Maven依赖传递 假如有Maven项目A,项目B依赖A,项目C依赖B.那么我们可 ...
- maven 依赖排除
在项目中遇到一个问题,项目使用spring 3.x,引用了某些包,这些包又依赖了spring2.x,造成项目无法启动.这种情况就需要用到maven的依赖排除,配置如下: 使用以下代码排除依赖xxxx引 ...
- Maven学习归纳(三)——依赖添加依赖排除与项目整合
一.Maven的坐标 1. 坐标的定义 数学意义上的坐标可以是平面上的(x,y)也可以是空间上的(x,y,z),都可以确定一个质点的位置和方向. Maven中有很多构件,为了能够自动化解析任何一个构件 ...
- 【Maven】Maven中排除依赖、归类依赖、优化依赖
参考博文:Maven中排除依赖.归类依赖.优化依赖
- 【转】Maven实战(七)---传递依赖
原博文出自于:http://blog.csdn.net/liutengteng130/article/details/47000069 感谢! 假设A-->C B-->A ...
- Maven学习(二) -- 坐标和依赖
标签(空格分隔): 学习笔记 坐标 实际就像在几何中,我们用一对坐标(x, y)来表示坐标系中唯一的点:或者我们可以用(经度,纬度)来表示地球上的某一个位置,在Maven的世界中,有坐标来唯一的表示项 ...
随机推荐
- PDF 补丁丁 0.4.2.1218 测试版发布:新增拆分文档功能
新的测试版的“提取页面”功能增加了拆分文档的选项. 可按照指定的页码范围(用“:”分号分割).顶层书签或指定页数三种方式,将一个 PDF 文档拆分成多个文档. 此功能还支持多个文档批量操作. 欢迎各位 ...
- 9_13学习完整修改和查询&&实体类,数据访问类
完整修改和查询:中间变量运用. 1.先查 2.执行操作 ---------------------------------------------------- namespace ADO.NET_小 ...
- jquery mobile 教程
简介:jQuery Mobile框架可以轻松的帮助我们实现非常好看的.可跨设备的Web应用程序.我们将后续的介绍中向大家介绍大量的代码及实例. jQuery一直以来都是非常流行的富客户端及Web应用程 ...
- 怎样将Sqlserver数据库转成mysql数据库
手上有一个网站之前是用asp.net做的,所使用的数据库是sqlserver,现在打算用PHP+MYSQL架构.因原来的站点有一定排名,直接改版的话,会导致产生很多错误页,网站排名和收录结果要恢复过来 ...
- 32个触发事件XSS语句的总结
1.onmouseenter:当鼠标进入选区执行代码 <div style="background-color:red" onmouseenter="alert(b ...
- 通过cpu SN码注册软件类
using System; using System.Management; namespace SoftReg { internal class SoftReg { #region 变量 ]; // ...
- css3隔行变换色实现示例
<style>#list1 li:nth-of-type(odd){ background:#00ccff;}/*奇数行*/ #list1 li:nth-of-type(even){ ba ...
- IOS演变史
我是从iOS5开始接触iPhone操作系统,对此系统也算是有爱有恨,今天从网上整理以下整个iOS发展的历史,了解了解也算做以后闲时讨论的一个话题. 电脑需要操作系统,手机也需要,2007年,苹果带着旗 ...
- HttpURLConnection发送和接受返回值
URL url = new URL(sb.toString());//请求的地址 HttpURLConnection connection = (HttpURLConnection) url.open ...
- 【winform 学习】C# 转换成JSON对象
C#里面对json的处理有2种,JavaScriptSerializer和DataContractJsonSerializer. JavaScriptSerializer读出来就是key-value ...