如何禁用Spring日志以获得我可以轻松阅读或其他人可以阅读的日志输出.在一个类似的问题,回答了如何禁用的Spring bean加载日志建议注释掉让所有线路org.springframework substring在log4j.properties file.在我的情况下,没有这样的线.
这是 log4j.properties
# Define the root logger with appender file
log4j.rootLogger = DEBUG, stdout
# Define the file appender
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# Set the name of the logs destination
log4j.appender.stdout.target=System.out
# Set the immediate flush to true (default)
log4j.appender.stdout.ImmediateFlush=true
# Set the threshold to debug mode
log4j.appender.stdout.Threshold=debug
# Set the append to false, overwrite
log4j.appender.stdout.Append=false
# Define the layout for appender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.conversionPattern=%d{yyyy-MM-dd}:%m%n
Run Code Online (Sandbox Code Playgroud) 在这些节目中我应该选择哪一个?为什么?一般来说问题是为什么我应该选择使用PriorityBlockingQueue优先于PriorityQueue.
的PriorityBlockingQueue
import java.util.concurrent.PriorityBlockingQueue;
public class PriorityBlockingQueueExample {
static PriorityBlockingQueue<String> priorityQueue = new PriorityBlockingQueue<String>();
public static void main(String[] args) {
new Thread(){
public void run(){
try {
System.out.println(priorityQueue.take() +" is removed from priorityQueue object");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}.start();
new Thread(){
public void run(){
priorityQueue.add("string variable");
System.out.println("Added an element to the queue");
}
}.start();
}
}
Run Code Online (Sandbox Code Playgroud)
在这些节目中我应该选择哪一个?为什么?一般来说问题是为什么我应该选择使用PriorityBlockingQueue优先于PriorityQueue.的PriorityQueue
import java.util.PriorityQueue;
public class PriorityQueueTest {
static PriorityQueue<String> priorityQueue = new PriorityQueue<String>();
private static …Run Code Online (Sandbox Code Playgroud) 守护程序线程为用户线程提供服务,除了gc可以使用守护程序线程的另一个示例(case)之外?(任何可以在实践中的run()方法内的任务(逻辑)daemon Thread)
我知道final关键字在方法上的一个用途是强制子类使用相同的方法实现.但是,通过允许编译器将对方法的调用转换为内联java代码来提高效率意味着什么呢?我刚看过这个,但不太明白这个想法.
在这种程度上,我不理解内联Java代码的含义.如何final执行对方法的调用?在编译调用final方法的代码的过程中,Java是否有任何特殊的通知或做什么?
为什么交易在没有的情况下回滚Exception?该对象未被保存.我已经定义了交易参数,如:
@Transactional(value = "transactionManager", timeout = 30, rollbackFor =
java.lang.Exception.class)`.
Run Code Online (Sandbox Code Playgroud)
这就是日志对交易的看法.
org.springframework.test.context.transaction.TransactionalTestExecutionListener
endTransaction
INFO: Rolled back transaction after test execution for test context [TestContext@51e2a069
testClass = DAOTest, testInstance = sample.library.dao.DAOTest@7591777e, testMethod =
testSaveDao@DAOTest, testException = [null], mergedContextConfiguration =
[MergedContextConfiguration@213c2d7f testClass = DAOTest, locations =
'{classpath:/applicationcontext.xml}', classes = '{}', contextInitializerClasses = '[]',
activeProfiles = '{}', contextLoader =
'org.springframework.test.context.support.DelegatingSmartContextLoader', parent =
[null]]]
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.634 sec
Run Code Online (Sandbox Code Playgroud)
这是整个DAOTest类的日志:
-------------------------------------------------------------------------------
Test …Run Code Online (Sandbox Code Playgroud) 我在哪里可以找到这个jar:clover:jar:1.3-rc4?由于缺少文件而导致错误后,我到了这一点,我想尝试一下最后一件事,就像我为stax所做的那样手动安装clover:jar:1.3-rc4