log4j2 ERROR StatusLogger未找到log4j2配置文件且ResourceBundle错误

时间:2016-02-11 10:15:32

标签: java maven executable-jar log4j2 resourcebundle

我在\ src \ main \ resources中的log4j2.xml下面(这是在类路径中):

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
    <Properties>
        <Property name="LOG_DIR">.</Property>
        <Property name="ARCHIVE">output.log</Property>
        <Property name="CONSOLE_PATTERN">[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n</Property>
        <Property name="FILE_PATTERN">%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Property>
    </Properties>
    <Appenders>
        <Console name="console" target="SYSTEM_OUT">
            <PatternLayout pattern="${CONSOLE_PATTERN}"/>
        </Console>
        <File name="file" fileName="${LOG_DIR}/${ARCHIVE}" immediateFlush="false" append="false">
            <PatternLayout pattern="${FILE_PATTERN}"/>
        </File>
    </Appenders>
    <Loggers>
        <Root level="INFO" additivity="false">
            <AppenderRef ref="console"/>
            <AppenderRef ref="file"/>
        </Root>
        <Logger name="com.my.package" level="TRACE" additivity="false">
            <AppenderRef ref="console"/>
            <AppenderRef ref="file"/>
        </Logger>
        <Logger name="com.my.package.errors" level="ERROR" additivity="false">
            <AppenderRef ref="console"/>
            <AppenderRef ref="file"/>        
        </Logger>
    </Loggers>
</Configuration>

如果我从eclipse运行应用程序,无论是调试还是运行,消息都会正确输出到控制台和文件。

我正在使用maven,并且我没有在maven pom.xml配置文件中对log4j进行任何依赖。

我试图按照here所述:

<dependencies>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.5</version>
  </dependency>
  <dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.5</version>
  </dependency>
</dependencies>

但是它不喜欢maven,并且pom.xml出现以下错误:

Failed to read artifact descriptor for org.apache.logging.log4j:log4j-api:jar:2.5

org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.logging.log4j:log4j-api:jar:2.5
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:302)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:218)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:535)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:519)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:409)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:363)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:351)
    at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:316)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:172)
    at org.apache.maven.project.DefaultProjectBuilder.resolveDependencies(DefaultProjectBuilder.java:215)
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:188)
    at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:119)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.readMavenProject(MavenImpl.java:636)
    at org.eclipse.m2e.core.internal.project.registry.DefaultMavenDependencyResolver.resolveProjectDependencies(DefaultMavenDependencyResolver.java:63)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refreshPhase2(ProjectRegistryManager.java:529)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:491)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:495)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:350)
    at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:297)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.getProjectFacade(MavenBuilder.java:154)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:89)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:205)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:245)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:300)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:303)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:359)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:382)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Failure to transfer org.apache.logging.log4j:log4j-api:pom:2.5 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.logging.log4j:log4j-api:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Connection refused: connect
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:287)
    ... 41 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer org.apache.logging.log4j:log4j-api:pom:2.5 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.logging.log4j:log4j-api:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Connection refused: connect
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238)
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:585)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:503)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)
    ... 44 more

所以我没有在maven中包含这些依赖项。无论如何没有这些依赖关系,如果我在eclipse IDE中调试或运行,我的应用程序运行良好。

我的问题在于部署我的应用。 通过eclipse导出向导,我选择&#34; export&#34;然后在Java下我选择Runnable JAR File。在下面的屏幕中,我检查&#34;将所需的库提取到生成的JAR&#34;中,并且创建jar文件没有问题。

最后,我尝试通过输入以下命令从控制台运行我的应用程序:

java -jar myapp.jar

但会出现以下错误消息:

ERROR StatusLogger No log4j2 configuration file found. Using default configurati
on: logging only errors to the console.
######## STARTING APP ################
######## ESTABLISHING CULTURE APP ################
Exception in thread "main" java.util.MissingResourceException: Can't find bundle
 for base name Strings, locale es_ES
        at java.util.ResourceBundle.throwMissingResourceException(Unknown Source
)
        at java.util.ResourceBundle.getBundleImpl(Unknown Source)
        at java.util.ResourceBundle.getBundle(Unknown Source)
        at com.distributed.analyzer.Main.establecerIdiomaLogging(Main.java:73)
        at com.distributed.analyzer.Main.main(Main.java:52)

从上面的错误可以看出,我检查了我的主要入口点是否被正确检测到:是的,它被正确检测到,在主要课程中我已经放了一些&#34; System.out.println&#34;当应用程序启动时,它们会显示,如上所示。问题是来自log4j2的消息没有在控制台中打印,因为似乎没有检测到log4j2.xml,它考虑了默认值,因此我的消息没有显示....

出现的最后一个错误与ResourceBundle有关。我有一个名为&#34; Strings_es_ES.properties&#34;的资源字符串。它位于与log4j2.xml相同的位置,即在/ src / main / resources /中,此路径位于我的类路径中。

那我做错了什么? 我怎样才能解决这2个错误? 我可以检查什么?

ATTEMPT1

正如hohenheim建议我尝试在log4j2条目下面手动安装:

<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.5</version>

<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>

但我收到错误。似乎尝试连接到apache存储库但连接被代理拒绝(我现在正在工作)。我稍后会在家里试试,

信息下方:

C:\Program Files\apache-maven-3.3.9\bin>mvn install:install-file -Dfile=D:\apache-log4j-2.5-bin -DgroupId=org.apache.logging.log4j -DartifactId=log4j-ap
i -Dversion=2.5 -Dpackaging=jar
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-clean-plugin:2.5: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or on
e of its dependencies could not be resolved: Failed to read artifact descriptor
for org.apache.maven.plugins:maven-clean-plugin:jar:2.5
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-install-plugin/2.4/maven-install-plugin-2.4.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-install-plugin:2.4: Plugin org.apache.maven.plugins:maven-install-plugin:2.4 o
r one of its dependencies could not be resolved: Failed to read artifact descrip
tor for org.apache.maven.plugins:maven-install-plugin:jar:2.4
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-deploy-plugin/2.7/maven-deploy-plugin-2.7.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-deploy-plugin:2.7: Plugin org.apache.maven.plugins:maven-deploy-plugin:2.7 or
one of its dependencies could not be resolved: Failed to read artifact descripto
r for org.apache.maven.plugins:maven-deploy-plugin:jar:2.7
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-site-plugin/3.3/maven-site-plugin-3.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-site-plugin:3.3: Plugin org.apache.maven.plugins:maven-site-plugin:3.3 or one
of its dependencies could not be resolved: Failed to read artifact descriptor fo
r org.apache.maven.plugins:maven-site-plugin:jar:3.3
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-antrun-plugin:1.3: Plugin org.apache.maven.plugins:maven-antrun-plugin:1.3 or
one of its dependencies could not be resolved: Failed to read artifact descripto
r for org.apache.maven.plugins:maven-antrun-plugin:jar:1.3
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-assembly-plugin:2.2-beta-5: Plugin org.apache.maven.plugins:maven-assembly-plu
gin:2.2-beta-5 or one of its dependencies could not be resolved: Failed to read
artifact descriptor for org.apache.maven.plugins:maven-assembly-plugin:jar:2.2-b
eta-5
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-dependency-plugin/2.8/maven-dependency-plugin-2.8.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-dependency-plugin:2.8: Plugin org.apache.maven.plugins:maven-dependency-plugin
:2.8 or one of its dependencies could not be resolved: Failed to read artifact d
escriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.8
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-release-plugin/2.3.2/maven-release-plugin-2.3.2.pom
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:mave
n-release-plugin:2.3.2: Plugin org.apache.maven.plugins:maven-release-plugin:2.3
.2 or one of its dependencies could not be resolved: Failed to read artifact des
criptor for org.apache.maven.plugins:maven-release-plugin:jar:2.3.2
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/mojo/maven-metada
ta.xml
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven
-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xm
l from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.
apache.org:443 [repo.maven.apache.org/185.31.17.215] failed: Connection refused:
 connect
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/
to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.
org:443 [repo.maven.apache.org/185.31.17.215] failed: Connection refused: connec
t
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from h
ttps://repo.maven.apache.org/maven2 was cached in the local repository, resoluti
on will not be reattempted until the update interval of central has elapsed or u
pdates are forced. Original error: Could not transfer metadata org.apache.maven.
plugins/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2
): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/185.31.17.215] fa
iled: Connection refused: connect
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from https://
repo.maven.apache.org/maven2 was cached in the local repository, resolution will
 not be reattempted until the update interval of central has elapsed or updates
are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-
metadata.xml from/to central (https://repo.maven.apache.org/maven2): Connect to
repo.maven.apache.org:443 [repo.maven.apache.org/185.31.17.215] failed: Connecti
on refused: connect
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.619 s
[INFO] Finished at: 2016-02-11T12:51:15+01:00
[INFO] Final Memory: 6M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'install' in the current project and in the p
lugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the re
positories [local (C:\Users\A\.m2\repository), central (https://repo.maven.apach
e.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundF
orPrefixException

C:\Program Files\apache-maven-3.3.9\bin>

ATTEMPT 2

我从eclipse执行mvn clean install之后在maven中安装了所有依赖项我收到以下错误?

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building analyzer 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.pom
[INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.12.4/maven-surefire-plugin-2.12.4.pom (11 KB at 4.0 KB/sec)
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire/2.12.4/surefire-2.12.4.pom
[INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire/2.12.4/surefire-2.12.4.pom (14 KB at 44.0 KB/sec)
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom
[INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom (6 KB at 26.3 KB/sec)
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ distributed.analyzer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ distributed.analyzer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 14 source files to D:\eclipse-workspace\DistributedAnalyzer\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.491 s
[INFO] Finished at: 2016-02-11T17:10:55+01:00
[INFO] Final Memory: 10M/117M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project distributed.analyzer: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

ATTEMPT 3

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building analyzer 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ distributed.analyzer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 9 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ distributed.analyzer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 14 source files to D:\eclipse-workspace\DistributedAnalyzer\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[10,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[23,30] cannot find symbol
  symbol:   class Logger
  location: class com.distributed.analyzer.Analizador
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[10,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[38,30] cannot find symbol
  symbol:   class Logger
  location: class com.distributed.analyzer.Ordenante
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[8,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[22,30] cannot find symbol
  symbol:   class Logger
  location: class com.distributed.analyzer.Manager
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[6,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[7,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[22,30] cannot find symbol
  symbol:   class Logger
  location: class com.distributed.analyzer.Main
[INFO] 12 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.057 s
[INFO] Finished at: 2016-02-11T17:35:25+01:00
[INFO] Final Memory: 16M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project distributed.analyzer: Compilation failure: Compilation failure:
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[10,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Analizador.java:[23,30] cannot find symbol
[ERROR] symbol:   class Logger
[ERROR] location: class com.distributed.analyzer.Analizador
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[10,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Ordenante.java:[38,30] cannot find symbol
[ERROR] symbol:   class Logger
[ERROR] location: class com.distributed.analyzer.Ordenante
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[8,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[9,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Manager.java:[22,30] cannot find symbol
[ERROR] symbol:   class Logger
[ERROR] location: class com.distributed.analyzer.Manager
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[6,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[7,32] package org.apache.logging.log4j does not exist
[ERROR] /D:/eclipse-workspace/DistributedAnalyzer/src/main/java/com/distributed/analyzer/Main.java:[22,30] cannot find symbol
[ERROR] symbol:   class Logger
[ERROR] location: class com.distributed.analyzer.Main
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

1 个答案:

答案 0 :(得分:0)

对于log4j.jar,您有错误:

Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Failure to transfer org.apache.logging.log4j:log4j-api:pom:2.5 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.logging.log4j:log4j-api:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Connection refused: connect

我认为这是代理问题,因为他无法连接到Maven Repository。 因此,您可以使用以下命令手动安装此jar:

mvn install:install-file -Dfile=<path to jar> -DgroupId=<group> -DartifactId=<artifact> -Dversion=<version> -Dpackaging=jar

然后使用相同的组,工件和版本在命令行(mvn install:install)中使用配置在pom.xml中声明它。 然后启动mvn clean install,就可以了。