Eclipse中Maven项目的类路径-src vs src/main/java
我试图将Eclipse中Maven项目的类路径-src vs src/main/java,java,eclipse,maven,logging,apache-commons-logging,Java,Eclipse,Maven,Logging,Apache Commons Logging,我试图将commons logging.properties添加到类路径中,该类路径将由commons logging.1.1.3.jar获取,默认情况下使用JDK14Logger,然后打印调试日志 当我将它添加到/src文件夹(一个普通的Java项目)下时,它是在RunAs->Java应用程序时被选中的 然而,对于一个Maven项目,我尝试将该文件放在项目根目录下的不同位置“src/main/java”、“src/main/resources”。当运行为->Java应用程序时,没有考虑它 只有
commons logging.properties
添加到类路径中,该类路径将由commons logging.1.1.3.jar
获取,默认情况下使用JDK14Logger,然后打印调试日志
当我将它添加到/src文件夹(一个普通的Java项目)下时,它是在RunAs->Java应用程序时被选中的
然而,对于一个Maven项目,我尝试将该文件放在项目根目录下的不同位置“src/main/java”、“src/main/resources”。当运行为->Java应用程序时,没有考虑它
只有通过以下VM参数显式指定时,才会拾取日志配置文件:
-Djava.util.logging.config.file=C:\ws-learning\spring-tutorial-5\commons-logging.properties
maven项目的类路径是什么
我应该将要拾取的配置文件放在哪里
为什么src/和src/main/java在类路径方面表现不同
更新:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
仅打印“信息”级别的消息。我看不到“良好”级别的消息
handlers=java.util.logging.ConsoleHandler,java.util.logging.FileHandler
.level=SEVERE
org.springframework.level=FINE
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.FileHandler.level=FINE
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
更新2:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
首先,确保已安装Maven integration for Eclipse。然后右键单击您的
apachecommonjava日志根目录project>Configure>configureasmaven项目
一旦您的项目启用了Maven,如果您认为Eclipse IDE偏离了Maven设置,请随时右键单击project>Maven
从pom.xml更新项目配置。正如@mm759所指出的,“src/main/resources”被选中。因为日志记录的工作方式,我感到困惑
“java.util.logging.config.file=”应该以VM参数的形式出现,或者在.properties文件中出现。“src/main/resources”是一个路径,在不太了解commons日志的情况下应该可以工作。@mm759请查看我的更新。只打印“信息”。如果它考虑了日志配置文件,它应该已经打印了“精细”级别的消息。您可以在Eclipse中右键单击该项目并查看“构建路径”。应包括“src/main/resources”。