我是Spring Shell框架的新手。我使用maven(mvn)存储库/工具构建/编程了Spring Shell。在它上面创建/添加新命令非常容易。
我发现我发现是围绕Spring Shell应用程序的启动和关闭,因为它在这个进程中输出了一些我当时无法禁用的LOG。
java -jar target/spring-shell-demo-1.0-SNAPSHOT.jar
Mar 04, 2014 9:47:20 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@d90727: startup date [Tue Mar 04 09:47:20 BRT 2014]; root of context hierarchy
Mar 04, 2014 9:47:20 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
:
-
spring-shell>quit
Closing org.springframework.context.support.ClassPathXmlApplicationContext@173180c: startup date [Tue Mar 04 09:51:17 BRT 2014]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@d90727
Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@f13e82: defining beans [readContainerCmd,getSubscriberAccountDetailsCmd,removeContainerCmd,addContainerCmd,getSubscriberDetailsCmd,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,deleteSubscriberCmd,createSubscriberCmd,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@1f7d3b1
:
我认为它可能是一个log4j配置,所以我创建了log4j.xml配置:
src/main/resources$ cat log4j.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="appender" class="org.apache.log4j.FileAppender">
<param name="File" value="helloWorld-Log.txt"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %p - %m%n"/>
</layout>
</appender>
<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.SimpleLayout"/>
</appender>
<root>
<priority value ="ERROR"/>
<appender-ref ref="ConsoleAppender"/>
</root>
</log4j:configuration>
我原以为这可以从启动和关闭中删除那些INFO日志,但它仍然是相同的。 正如你所看到的,我已经在资源文件夹中创建了log4j.xml ...我不确定它应该在另一条路径中,但我几乎试图把它放在每个地方。
我很感激有关如何解决此问题的任何帮助/提示。
此致
Spring Shell配置的其他信息:
src/main/resources/META-INF/spring$ cat spring-shell-plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.xx.yy" />
<context:component-scan base-package="com.xx.zz" />
</beans>
答案 0 :(得分:0)
这对我有用:
public static void main(String[] args) throws IOException {
LogManager.getLogManager().reset();
Bootstrap.main(args);
}