当前位置: 首页 > 知识库问答 >
问题:

Log4j2+MongoDb不工作

厍彭薄
2023-03-14

我尝试配置log4j2以在gradle项目中使用MongoDB,当我在Eclipse和测试中运行时,它工作得很好,但是当我生成一个jar并启动它时,我得到一个错误:

2018-08-13 09:30:11,534主要错误找不到MongoDb的插件类型2018-08-13 09:30:11,548主要错误找不到MongoDb的插件2018-08-13 09:30:11,597主要错误无法为元素NoSQL:java.lang.NullPointerException创建类型为org.apache.logging.log4j.Core.Appender.NoSQLAppender的插件:在org.apache.logging.log4j.Core.Config.Plugins.Visitor.PluginElementVisitor.FindNamedNode(tConfiguration.Java:899)位于org.apache.logging.log4j.core.configuration(abstractConfiguration.Java:891)位于org.apache.logging.log4j.core.configuration(abstractConfiguration.Java:514)位于org.apache.logging.log4j.core.configuration(abstractConfiguration.Java:doConfiguration(abstractConfiguration.Java:238)位于org.apache.logging.log4j.core.configuration(log4j.logmanager.getContext(logmanager.java:194)在org.apache.logging.log4j.logmanager.getLogger(logmanager.java:581)在br.com.serversocket.main.main.(main.java:15)

2018-08-13 09:30:11,607主要错误无法为元素NoSQL调用org.apache.logging.log4j.core.appender.nosql.nosqlappender类中的工厂方法:java.lang.IllegalStateException:找不到org.apache.logging.log4j.core.appender.nosql.nosqlappender类的工厂方法:找不到org.apache.logging.log4j.core.config.plugins.util.pluginbuilder.findFactoryMethod(tConfiguration.doConfigure(abstractConfiguration.Java:514)在org.apache.logging.log4j.core.config.abstractConfiguration.initialize(abstractConfiguration.Java:238)在org.apache.logging.log4j.core.config.abstractConfiguration.start(abstractConfiguration.Java:250)在org.apache.logging.log4j.core.loggercontext.setconfiguration(loggercontext.547)在

2018-08-13 09:30:11,617主要错误为附件中的NoSql返回了空对象。2018-08-13 09:30:11,655主错误找不到记录器配置“root”的附加器“nosql”

我的log4j2.yaml:

Configuration:
  status: WARN
  appenders:    
    NoSql:
      name: NoSql
      MongoDb:
        databaseName: tracker
        collectionName: appLog
        server: ds261755.mlab.com
        port: 61755
        username: admin
        password: XXXXX
  Loggers:
    logger:
      -
        name: com.memorynotfound
        level: info
      -
        name: com.mchange.v2.c3p0
        level: warn
    Root:
      level: info
      AppenderRef:
        ref: NoSql

我的建筑。格雷德尔:

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
archivesBaseName = 'ServerSocket'
version = '3.2.1'

mainClassName = 'br.com.serversocket.main.Main'

compileTestJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

compileJava {
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

jar {
    dependsOn 'test'
    archiveName = "ServerSocket.jar"
    from {
        configurations.runtime.collect {
            it.isDirectory() ? it : zipTree(it)
        }

        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }

    manifest {
        attributes 'Main-Class': 'br.com.serversocket.main.Main'
    }

    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

test{
    useJUnitPlatform()
    dependsOn 'cleanTest'

    testLogging {
        events "passed", "skipped", "failed"
    }
    afterTest { desc, result -> 
        logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
    }
    testLogging {
        exceptionFormat = 'full'
    }   
}

eclipse.classpath.file.whenMerged {
  entries.each { println it.path }
}
configurations { 
    providedCompile 
}

repositories {
    mavenCentral()
    mavenLocal()
}

ext {
    jacksonVersion = '2.9.1'
    hibernateVerison = '5.1.0.Final'
    slf4jVerison = '1.7.25'
    log4jVerison = '2.11.1'
    junitVersion = '5.2.0'
    emailVersion = '1.6.1'
}

dependencies {

    //compile files(fileTree(dir: 'lib', includes: ['*.jar']))  
    compile "org.hibernate:hibernate-jpamodelgen:${hibernateVerison}"
    compile "org.hibernate:hibernate-c3p0:${hibernateVerison}"
    compile "org.hibernate:hibernate-core:${hibernateVerison}"
    compile "org.hibernate:hibernate-entitymanager:${hibernateVerison}"

    compile "org.slf4j:slf4j-simple:${slf4jVerison}"
    compile "org.slf4j:slf4j-api:${slf4jVerison}"

    compile "org.apache.logging.log4j:log4j-slf4j-impl:${log4jVerison}"
    compile "org.apache.logging.log4j:log4j-api:${log4jVerison}"
    compile "org.apache.logging.log4j:log4j-core:${log4jVerison}"
    compile "org.apache.logging.log4j:log4j-nosql:2.9.1"
    compile "org.apache.logging.log4j:log4j-jcl:${log4jVerison}"


    compile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
    compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
    compile "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
    compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"

    compile "javax.mail:javax.mail-api:${emailVersion}"
    compile "com.sun.mail:javax.mail:${emailVersion}"

    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.2'
    compile group: 'org.yaml', name: 'snakeyaml', version: '1.21'

    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.44'
    compile group: 'org.hibernate.common', name: 'hibernate-commons-annotations', version: '5.0.1.Final'
    compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.2.Final'
    compile group: 'com.mchange', name: 'c3p0', version: '0.9.2.1'
    compile group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.1.0'
    compile group: 'org.jboss.logging', name: 'jboss-logging', version: '3.3.1.Final'
    compile group: 'commons-logging', name: 'commons-logging', version: '1.0.3'
    compile group: 'org.apache.mina', name: 'mina-core', version: '2.0.19'
    compile group: 'antlr', name: 'antlr', version: '2.7.7'
    compile group: 'com.fasterxml', name: 'classmate', version: '1.3.0'
    compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
    compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.6'
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2.1'
    compile group: 'org.apache.commons', name: 'commons-email', version: '1.5'
    compile group: 'commons-httpclient', name: 'commons-httpclient', version: '3.1'
    compile group: 'commons-lang', name: 'commons-lang', version: '2.3'
    compile group: 'commons-discovery', name: 'commons-discovery', version: '0.2'
    compile group: 'dom4j', name: 'dom4j', version: '1.6.1'
    compile group: 'net.sf.ehcache', name: 'ehcache', version: '1.5.0'
    compile group: 'org.apache.geronimo.specs', name: 'geronimo-jta_1.1_spec', version: '1.1.1'
    compile group: 'org.jboss', name: 'jandex', version: '2.0.3.Final'
    compile group: 'org.javassist', name: 'javassist', version: '3.22.0-GA'
    compile group: 'jdom', name: 'jdom', version: '1.1'
    compile group: 'javax.transaction', name: 'jta', version: '1.1'
    compile group: 'com.vividsolutions', name: 'jts', version: '1.13'
    compile group: 'org.apache.axis', name: 'axis', version: '1.4'
    compile group: 'axis', name: 'axis-jaxrpc', version: '1.4'
    compile group: 'javax.xml.soap', name: 'saaj-api', version: '1.3'
    compile group: 'wsdl4j', name: 'wsdl4j', version: '1.6.2'
    compile group: 'com.mchange', name: 'mchange-commons-java', version: '0.2.3.4'
    compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.8.0'


    testCompile group: 'com.h2database', name: 'h2', version: '1.4.197'
    testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
    testCompile "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
    testCompile "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
    testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.2.0'
}

configurations {
    all*.exclude group: 'javassist', module: 'javassist'
}

我的问题出在配置上?我需要做什么?

[编辑]

我更改一些配置:

Build.Gradle:

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
archivesBaseName = 'ServerSocket'
version = '3.2.1'

mainClassName = 'br.com.serversocket.main.Main'

compileTestJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

compileJava {
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

jar {
    //dependsOn 'test'
    archiveName = "ServerSocket.jar"
    from {
        configurations.runtime.collect {
            it.isDirectory() ? it : zipTree(it)
        }

        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }

    manifest {
        attributes 'Main-Class': 'br.com.serversocket.main.Main'
    }

    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

test{
    useJUnitPlatform()
    dependsOn 'cleanTest'

    testLogging {
        events "passed", "skipped", "failed"
    }
    afterTest { desc, result -> 
        logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
    }
    testLogging {
        exceptionFormat = 'full'
    }   
}

eclipse.classpath.file.whenMerged {
  entries.each { println it.path }
}
configurations { 
    providedCompile 
}

repositories {
    mavenCentral()
    mavenLocal()
}

ext {
    jacksonVersion = '2.9.1'
    hibernateVerison = '5.1.0.Final'
    slf4jVerison = '1.7.25'
    log4jVerison = '2.11.1'
    junitVersion = '5.2.0'
    emailVersion = '1.6.1'
    mongoDBVersion = '3.8.0'
}

dependencies {

    //compile files(fileTree(dir: 'lib', includes: ['*.jar']))  
    compile "org.hibernate:hibernate-jpamodelgen:${hibernateVerison}"
    compile "org.hibernate:hibernate-c3p0:${hibernateVerison}"
    compile "org.hibernate:hibernate-core:${hibernateVerison}"
    compile "org.hibernate:hibernate-entitymanager:${hibernateVerison}"

    compile "org.slf4j:slf4j-simple:${slf4jVerison}"
    compile "org.slf4j:slf4j-api:${slf4jVerison}"

    compile "org.apache.logging.log4j:log4j-api:${log4jVerison}"
    compile "org.apache.logging.log4j:log4j-core:${log4jVerison}"
    compile "org.apache.logging.log4j:log4j-jcl:${log4jVerison}"
    compile "org.apache.logging.log4j:log4j-mongodb3:${log4jVerison}"
    //compile "org.apache.logging.log4j:log4j-nosql:${log4jVerison}"

    compile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
    compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
    compile "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
    compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"

    compile "javax.mail:javax.mail-api:${emailVersion}"
    compile "com.sun.mail:javax.mail:${emailVersion}"

    //compile "org.mongodb:mongo-java-driver:${mongoDBVersion}"
    compile "org.mongodb:mongodb-driver:${mongoDBVersion}"
    compile "org.mongodb:mongodb-driver-core:${mongoDBVersion}"
    compile "org.mongodb:bson:${mongoDBVersion}"


    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.2'
    compile group: 'org.yaml', name: 'snakeyaml', version: '1.21'

    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.44'
    compile group: 'org.hibernate.common', name: 'hibernate-commons-annotations', version: '5.0.1.Final'
    compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.2.Final'
    compile group: 'com.mchange', name: 'c3p0', version: '0.9.2.1'
    compile group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.1.0'
    compile group: 'org.jboss.logging', name: 'jboss-logging', version: '3.3.1.Final'
    compile group: 'commons-logging', name: 'commons-logging', version: '1.0.3'
    compile group: 'org.apache.mina', name: 'mina-core', version: '2.0.19'
    compile group: 'antlr', name: 'antlr', version: '2.7.7'
    compile group: 'com.fasterxml', name: 'classmate', version: '1.3.0'
    compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
    compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.6'
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2.1'
    compile group: 'org.apache.commons', name: 'commons-email', version: '1.5'
    compile group: 'commons-httpclient', name: 'commons-httpclient', version: '3.1'
    compile group: 'commons-lang', name: 'commons-lang', version: '2.3'
    compile group: 'commons-discovery', name: 'commons-discovery', version: '0.2'
    compile group: 'dom4j', name: 'dom4j', version: '1.6.1'
    compile group: 'net.sf.ehcache', name: 'ehcache', version: '1.5.0'
    compile group: 'org.apache.geronimo.specs', name: 'geronimo-jta_1.1_spec', version: '1.1.1'
    compile group: 'org.jboss', name: 'jandex', version: '2.0.3.Final'
    compile group: 'org.javassist', name: 'javassist', version: '3.22.0-GA'
    compile group: 'jdom', name: 'jdom', version: '1.1'
    compile group: 'javax.transaction', name: 'jta', version: '1.1'
    compile group: 'com.vividsolutions', name: 'jts', version: '1.13'
    compile group: 'org.apache.axis', name: 'axis', version: '1.4'
    compile group: 'axis', name: 'axis-jaxrpc', version: '1.4'
    compile group: 'javax.xml.soap', name: 'saaj-api', version: '1.3'
    compile group: 'wsdl4j', name: 'wsdl4j', version: '1.6.2'
    compile group: 'com.mchange', name: 'mchange-commons-java', version: '0.2.3.4'


    testCompile group: 'com.h2database', name: 'h2', version: '1.4.197'
    testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
    testCompile "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
    testCompile "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
    testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.2.0'
}

configurations {
    all*.exclude group: 'javassist', module: 'javassist'
}

log4j2.yaml:

Configuration:
  status: WARN
  appenders:    
    NoSql:
      name: databaseAppender
      MongoDb3:
        databaseName: tracker
        collectionName: appLog
        server: ds261755.mlab.com
        port: 61755
        username: admin
        password: xxxx

  Loggers:
    logger:
      -
        name: com.memorynotfound
        level: info
      -
        name: com.mchange.v2.c3p0
        level: warn
    Root:
      level: info
      AppenderRef:
        ref: databaseAppender

然后我会收到一条新的错误消息:

2018-08-14 10:29:26,690 main ERROR Unable to locate plugin type for MongoDb3
2018-08-14 10:29:26,703 main ERROR Unable to locate plugin for MongoDb3
2018-08-14 10:29:26,753 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.nosql.NoSqlAppender for element NoSql: java.lang.NullPointerException java.lang.NullPointerException
    at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.findNamedNode(PluginElementVisitor.java:103)
    at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:87)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:181)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
    at br.com.serversocket.main.Main.<clinit>(Main.java:15)

2018-08-14 10:29:26,764 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.nosql.NoSqlAppender for element NoSql: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.nosql.NoSqlAppender java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.appender.nosql.NoSqlAppender
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:235)
    at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:959)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:899)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:891)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:514)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:238)
    at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:250)
    at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:547)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:619)
    at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:636)
    at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:231)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:153)
    at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
    at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581)
    at br.com.serversocket.main.Main.<clinit>(Main.java:15)

2018-08-14 10:29:26,773 main ERROR Null object returned for NoSql in appenders.
2018-08-14 10:29:26,813 main ERROR Unable to locate appender "databaseAppender" for logger config "root"

我检查了类的log4j-core,试图更好地理解该错误,并发现了以下方法:

protected void preConfigure(final Node node) {
    try {
        for (final Node child : node.getChildren()) {
            if (child.getType() == null) {// problem happen here in production
                LOGGER.error("Unable to locate plugin type for " + child.getName());
                continue;
            }
            final Class<?> clazz = child.getType().getPluginClass();
            if (clazz.isAnnotationPresent(Scheduled.class)) {
                configurationScheduler.incrementScheduledItems();
            }
            preConfigure(child);
        }
    } catch (final Exception ex) {
        LOGGER.error("Error capturing node data for node " + node.getName(), ex);
    }
} 

当我在IDE中运行项目时,一个节点的属性“getType()”是“plugintype[pluginclass=class org.apache.logging.log4j.mongoDB3.mongoDBProvider,key=mongoDB3,elementname=mongoDB3,isobjectprintable=true,isdeferChildren==false,category=core]”,但我生产时,我想jar是怎么在log4j-mongoDB3中找不到类的。我检查了生成的jar,但类的打包没有问题。发生什么事了?

[编辑]

我发现了我的问题,我创建了一个没有gradle的测试项目,我生成了一个jar,我需要复制依赖项而不是提取它们,我如何配置gradle在jar任务中做到这一点?

共有1个答案

欧阳永宁
2023-03-14

我用2级的插件解决了我的问题:

影子:http://imperceptiblethoughts.com/shadow/#shadowing_gradle_plugins

和此插件来修复与log4j之间的不可比性:

https://github.com/theboegl/shadow-log4j-transformer#using-the-gradle-plugin-dsl

跟着我的建筑走。格雷德尔:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
        classpath 'de.sebastianboegl.gradle.plugins:shadow-log4j-transformer:2.2.0'
    }
}

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'com.github.johnrengelman.shadow'
archivesBaseName = 'ServerSocket'
version = '3.2.1'

mainClassName = 'br.com.serversocket.main.Main'

compileTestJava {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}

compileJava {
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

shadowJar {
    //dependsOn 'test'
    transform(de.sebastianboegl.gradle.plugins.shadow.transformers.Log4j2PluginsFileTransformer)
    archiveName = "ServerSocket.jar"

    manifest {
        attributes 'Main-Class': 'br.com.serversocket.main.Main'
    }

    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

jar {
    //dependsOn 'test'
    archiveName = "ServerSocket.jar"
    from {
        configurations.runtime.collect {
            it.isDirectory() ? it : zipTree(it)
        }

        configurations.compile.collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }

    manifest {
        attributes 'Main-Class': 'br.com.serversocket.main.Main'
    }

    exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
}

test{
    useJUnitPlatform()
    dependsOn 'cleanTest'

    testLogging {
        events "passed", "skipped", "failed"
    }
    afterTest { desc, result -> 
        logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
    }
    testLogging {
        exceptionFormat = 'full'
    }   
}

eclipse.classpath.file.whenMerged {
  entries.each { println it.path }
}
configurations { 
    providedCompile 
}

repositories {
    mavenCentral()
    mavenLocal()
}

ext {
    jacksonVersion = '2.9.1'
    hibernateVerison = '5.1.0.Final'
    slf4jVerison = '1.7.25'
    log4jVerison = '2.11.1'
    junitVersion = '5.2.0'
    emailVersion = '1.6.1'
    mongoDBVersion = '3.8.0'
}

dependencies {

    //compile files(fileTree(dir: 'lib', includes: ['*.jar']))  
    compile "org.hibernate:hibernate-jpamodelgen:${hibernateVerison}"
    compile "org.hibernate:hibernate-c3p0:${hibernateVerison}"
    compile "org.hibernate:hibernate-core:${hibernateVerison}"
    compile "org.hibernate:hibernate-entitymanager:${hibernateVerison}"

    compile "org.slf4j:slf4j-simple:${slf4jVerison}"
    compile "org.slf4j:slf4j-api:${slf4jVerison}"

    compile "org.apache.logging.log4j:log4j-api:${log4jVerison}"
    compile "org.apache.logging.log4j:log4j-core:${log4jVerison}"
    compile "org.apache.logging.log4j:log4j-mongodb3:${log4jVerison}"


    compile "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
    compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
    compile "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
    compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"

    compile "javax.mail:javax.mail-api:${emailVersion}"
    compile "com.sun.mail:javax.mail:${emailVersion}"

    compile "org.mongodb:mongodb-driver:${mongoDBVersion}"
    compile "org.mongodb:mongodb-driver-core:${mongoDBVersion}"
    compile "org.mongodb:bson:${mongoDBVersion}"


    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.2'
    compile group: 'org.yaml', name: 'snakeyaml', version: '1.21'

    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.44'
    compile group: 'org.hibernate.common', name: 'hibernate-commons-annotations', version: '5.0.1.Final'
    compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.2.Final'
    compile group: 'com.mchange', name: 'c3p0', version: '0.9.2.1'
    compile group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.1.0'
    compile group: 'org.jboss.logging', name: 'jboss-logging', version: '3.3.1.Final'
    compile group: 'commons-logging', name: 'commons-logging', version: '1.0.3'
    compile group: 'org.apache.mina', name: 'mina-core', version: '2.0.19'
    compile group: 'antlr', name: 'antlr', version: '2.7.7'
    compile group: 'com.fasterxml', name: 'classmate', version: '1.3.0'
    compile group: 'commons-codec', name: 'commons-codec', version: '1.11'
    compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.6'
    compile group: 'commons-collections', name: 'commons-collections', version: '3.2.1'
    compile group: 'org.apache.commons', name: 'commons-email', version: '1.5'
    compile group: 'commons-httpclient', name: 'commons-httpclient', version: '3.1'
    compile group: 'commons-lang', name: 'commons-lang', version: '2.3'
    compile group: 'commons-discovery', name: 'commons-discovery', version: '0.2'
    compile group: 'dom4j', name: 'dom4j', version: '1.6.1'
    compile group: 'net.sf.ehcache', name: 'ehcache', version: '1.5.0'
    compile group: 'org.apache.geronimo.specs', name: 'geronimo-jta_1.1_spec', version: '1.1.1'
    compile group: 'org.jboss', name: 'jandex', version: '2.0.3.Final'
    compile group: 'org.javassist', name: 'javassist', version: '3.22.0-GA'
    compile group: 'jdom', name: 'jdom', version: '1.1'
    compile group: 'javax.transaction', name: 'jta', version: '1.1'
    compile group: 'com.vividsolutions', name: 'jts', version: '1.13'
    compile group: 'org.apache.axis', name: 'axis', version: '1.4'
    compile group: 'axis', name: 'axis-jaxrpc', version: '1.4'
    compile group: 'javax.xml.soap', name: 'saaj-api', version: '1.3'
    compile group: 'wsdl4j', name: 'wsdl4j', version: '1.6.2'
    compile group: 'com.mchange', name: 'mchange-commons-java', version: '0.2.3.4'


    testCompile group: 'com.h2database', name: 'h2', version: '1.4.197'
    testCompile "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
    testCompile "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
    testCompile "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
    testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.2.0'
}

configurations {
    all*.exclude group: 'javassist', module: 'javassist'
}
 类似资料:
  • 我正在使用log4j 2.4,并尝试将转换为,但是似乎不能使用log4j2.properties。 null 虽然以下文档https://logging.apache.org/log4j/2.x/manual/configuration.html#属性 清楚地表明 属性配置文件支持广告客户、monitorInterval、name、packages、shutdownHook、status 我也尝试

  • 专家。 我对MongoDB是新手,但知道的足以让我自己陷入困境…一个恰当的例子是:

  • 我正在尝试在WebLogic 12.2.1下运行的Web服务中添加log4j日志记录,但不知何故日志记录不起作用。 这是我的WAR文件WEB-INF\classes中的log4j2.xml: 这是我的Web服务代码的片段: 在我的WAR文件的WEB-INF\lib\中,我有: 我可以使用客户端程序成功调用web服务。但我根本没有看到日志文件被创建。有什么问题? 提前感谢。

  • 根据这里,Log4j2应该与Tomcat7.0.47一起工作。我用的是TomEE Plus 7.0.47。 SLF4J-API-1.7.5.jar log4j-api-2.0-rc1.jar log4j-core-2.0-rc1.jar log4j-SLF4j-impl-2.0-rc1.jar 如果我将配置状态更改为TRACE,我可以看到我的配置文件被拾取,并且配置按预期进行。我还可以看到MBea

  • 我有运行以下命令: 使用以下脚本可以插入文档: 插入. js 这是输出: 并且我运行方法,显示了文档(这就是我知道插入工作正常的原因): find.js 这是输出: 问题是我在MongoDB shell中看不到文档,我试过这个: 通过以下方式连接到MongoDB shell: 在MongoDB外壳中,我可以看到我的数据库(mytestingdb): 并更改为我想要的数据库: 我可以看到我的收藏(e

  • 我有一个maven项目,它使用log4j2进行日志记录。我想覆盖RootLogger的模式。 这是我的log4j2。属性文件: 这是我的pom。log4j的xml文件: 我这样叫我的记录仪: 我的配置有两个问题。第一个是根记录器不使用我的ConsolePender(警告等以默认格式显示),在记录错误时,我只得到第一行,而不是整个堆栈跟踪)。