小编DB5*_*DB5的帖子

多个SLF4J绑定与activemq-all-5.6.0.jar出错

当我升级到activemq-all-5.6.0时

我在服务器启动时遇到此错误

SLF4J:类路径包含多个SLF4J绑定

使用activemq-all-5.5.1时我没有这个问题

在检查时,我发现在activemq-all-5.6.0.jar和slf4j-log4j12-1.5.10.jar中都存在StaticLoggerBinder.class,这导致了问题

请帮忙调试此问题

我的pom.xml如下

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.5.10</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>jcl-over-slf4j</artifactId>
    <version>1.5.10</version>
    <scope>runtime</scope>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.5.10</version>
    <scope>runtime</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)

活动的mq依赖是这样的

旧版本5.5.1(此作品)

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>5.5.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

新版本5.6.0(这给出了错误)

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-all</artifactId>
    <version>5.6.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

提前致谢.

activemq-classic slf4j maven

26
推荐指数
2
解决办法
1万
查看次数

Maven Shade Plugin生产两个罐子

直到现在我使用maven程序集插件为每个工件生成两个JAR - 编译源和依赖项 - 原因很简单 - 仅通过网络部署已编译的源比使用40 MB部署一体式JAR要快得多数据的.

由于覆盖了内部文件,我不得不切换maven shade插件才能使用该<transformers>功能.但是我无法管理两个执行:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <executions>
      <execution>
        <id>shade-libs</id>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <outputFile>target/assembly/${project.artifactId}-libs.jar</outputFile>
          <artifactSet>
            <excludes>
              <exclude>...</exclude>
            </excludes>
          </artifactSet>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>META-INF/spring.handlers</resource>
            </transformer>
            <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
              <resource>META-INF/spring.schemas</resource>
            </transformer>
          </transformers>
        </configuration>
      </execution>
    </executions>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <executions>
      <execution>
        <id>shade-main</id>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <outputFile>target/assembly/${project.artifactId}.jar</outputFile>
          <artifactSet>
            <includes>
              <include>...</include>
            </includes>
          </artifactSet>
        </configuration>
      </execution>
    </executions>
  </plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)

当我运行时mvn package,只运行第二次执行.第一个总是被忽略.使用maven程序集插件,它运行得很好.

当然解决方案可能是同时使用装配和阴影插件,但我想找到更一致的解决方案.

maven maven-assembly-plugin maven-shade-plugin

13
推荐指数
1
解决办法
9059
查看次数

Maven java编译错误无法访问CommonClassA

背景:

  • 我正在开发Maven多模块项目.
  • 其中一个模块是其他所有模块所需的通用模块.
  • 该模块包含CommonClassA.java.
  • 通用模块已正确编译.
  • 它正确安装到maven本地存储库中.
  • 一类(的Billtype.java其他模块(EmployeeBilling))是指由此类(CommonClassA.java).
  • 在EmployeeBilling模块的pom.xml中正确指定了公共模块的Maven依赖关系.

问题:

在编译EmployeeBilling模块时,它会抛出

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project EmployeeBilling: Compilation failure
[ERROR] \MyWorkspace\Biz\EmployeeBilling\src\main\java\com\employee\Billtype.java:[79,19] error: cannot access CommonClassA
[ERROR] -> [Help 1]**
Run Code Online (Sandbox Code Playgroud)

支持细节:

  • EmployeeBilling> pom.xml中定义的依赖项:

  • 公共模块中的其他类似乎可以访问,因为没有观察到错

  • 没有其他错误,如找不到类/找不到文件.
  • CommonCLassA类实现了Serializable
  • Eclipse和commond line也出现相同的错误
  • 我正在使用M2E插件

工具:

  • jdk1.7.0_02
  • 操作系统:Windows 7
  • Eclipse JUNO和apache-maven-3.1.0

提前致谢!

compiler-errors maven multi-module

8
推荐指数
1
解决办法
1万
查看次数

如何循环目录中的文件,并根据每个文件名执行一些任务?

properties我的项目中有一个目录:

properties
    - project_dev.properties
    - project_test.properties
    - project_prod.properties
    - project_other.properties
Run Code Online (Sandbox Code Playgroud)

它为不同的环境定义了一些不同的值.还有一个template目录,其中包含一些带占位符的配置文件模板.

我想要做的是循环所有文件properties,并将每个文件组合到template目录中以生成最终配置文件,这些文件位于基于文件名的不同目录下.

所以它将是:

target
   - configurations
       - dev
            - ... some files
       - test
            - ... some files
       - prod
            - ... some files
       - other
            - ... some files
Run Code Online (Sandbox Code Playgroud)

我现在正在做的是使用maven-resources-plugin,并execution为每个文件定义几个s,并对名称进行硬编码.

看起来像:

<plugin>
    <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
            <!--- for dev ---->
            <execution>
                <id>dev-filter</id>
                <phase>validate</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <outputDirectory>${basedir}/target/conf/dev</outputDirectory>
                    <useDefaultDelimiters>false</useDefaultDelimiters>
                    <resources>
                        <resource>
                        <directory>${basedir}/conf/template</directory>
                        <filtering>true</filtering>
                        <includes>
                            <include>channel/*</include>
                            <include>rule-config/*</include>
                            <include>server/*.properties</include>
                        </includes> …
Run Code Online (Sandbox Code Playgroud)

loops maven

7
推荐指数
1
解决办法
6447
查看次数

使用mvn appengine更新Appengine时出现错误请求:update

当我尝试使用appengine-maven-plugin更新appengine-application时,我收到以下错误:

400 Bad Request
Error when loading application configuration:
Unable to assign value '1.8.3' to attribute 'version':
Value '1.8.3' for version does not match expression '^(?:^(?!-)[a-z\d\-]{0,62}[a-z\d]$)$'
Run Code Online (Sandbox Code Playgroud)

这让我感到困惑,因为我的appengine-web.xml如下所示:

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <application>helloworld</application>
    <version>0-0-1</version>
    <threadsafe>true</threadsafe>
    <precompilation-enabled>false</precompilation-enabled>

    <system-properties>
        <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
    </system-properties>
</appengine-web-app>
Run Code Online (Sandbox Code Playgroud)

我想知道为什么appengine-maven-plugin想要使用1.8.3作为应用程序版本.1.8.3是我想要使用的appengine-sdk的版本.在我的POM中,它配置如下:

<dependency>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-api-1.0-sdk</artifactId>
    <version>${appengine.version}</version>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

后来

<plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>${appengine.version}</version>
    <configuration>
        <appVersion>${appengine.app.version}</appVersion>
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

$ {appengine.app.version}指向1.8.3我在版本3.1和Java 1.7.0_25中使用Maven

我错了什么?任何人都可以帮我吗?非常感谢

google-app-engine maven-plugin

7
推荐指数
2
解决办法
3030
查看次数

Maven:为什么我可以运行mvn checkstyle:checkstyle而不用pom.xml配置?

我正在使用一个基本的maven项目,其中只在pom.xml中定义了以下内容:

  • 依赖javaee-api
  • 依赖junit
  • 插件maven-compile-plugin
  • 插件maven-war-plugin
  • 插件wildfly-maven-plugin

为什么我可以mvn checkstyle:checkstyle在命令窗口中运行?我不应该定义checkstyle插件pom.xml吗?我错过了什么?

编辑:安装了eclipse插件"Eclipse Checkstyle Plug-In".这是什么原因?如果是的话,maven如何与之沟通?

checkstyle pom.xml maven

7
推荐指数
1
解决办法
1952
查看次数

使用Maven构建JavaFX 8

我测试了使用Netbeans 7.4创建JavaFX 8项目.但遗憾的是没有运气.这是POM文件:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.dx57dc</groupId>
    <artifactId>JFX8M</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>JFX8M</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mainClass>com.dx57dc.jfx8m.MainApp</mainClass>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeScope>system</excludeScope>
                            <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>

                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/../bin/javafxpackager</executable>
                            <arguments>
                                <argument>-createjar</argument>
                                <argument>-nocss2bin</argument>
                                <argument>-appclass</argument>
                                <argument>${mainClass}</argument>
                                <argument>-srcdir</argument>
                                <argument>${project.build.directory}/classes</argument>
                                <argument>-outdir</argument>
                                <argument>${project.build.directory}</argument>
                                <argument>-outfile</argument>
                                <argument>${project.build.finalName}.jar</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>  
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArguments>
                        <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath> …
Run Code Online (Sandbox Code Playgroud)

maven-plugin maven-3 maven javafx-8

6
推荐指数
1
解决办法
2万
查看次数

maven pom.xml抱怨执行无法解析依赖关系但功能正常

我有一个使用WSDL服务的Java项目.pom给出了一个错误(所以我的项目中有红色X)但是所有内容都构建并正确运行.我很难过,任何想法都是适当的.

这是麻烦制造者:

< !-- WSDL stub generation -- >
<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId >cxf-codegen-plugin</artifactId>
    <version>${cxf-codegen-plugin.version}</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/wsdl/Service.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

这是我从上面的执行元素得到的错误:

执行生成目标org.apache.cxf:cxf-codegen-plugin:2.7.2:wsdl2java失败:插件org.apache.cxf:cxf-codegen-plugin:2.7.2或其中一个依赖项无法解析:无法收集org.apache.cxf的依赖项:cxf-codegen-plugin:jar:2.7.2()(org.apache.cxf:cxf-codegen-plugin:2.7.2:wsdl2java:generate-sources:generate-源)

(对不起'<'和'>'周围的空格.我是SO的新手,还不能张贴图片.

java eclipse wsdl2java pom.xml maven

5
推荐指数
1
解决办法
840
查看次数

Maven Jetty插件stopPort和stopKey丢失或无效

我正在学习Maven并遇到了问题.当我尝试使用我的webapp进行mvn clean install时,我得到错误,说参数stopPort和stopKey丢失或无效.这是pom.xml的样子:

    <plugin>
       <groupId>org.mortbay.jetty</groupId>
       <artifactId>maven-jetty-plugin</artifactId>
       <version>6.1.17</version>
       <executions>
         <execution>
            <id>start-jetty</id>
            <phase>pre-integration-test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <scanIntervalSeconds>0</scanIntervalSeconds>
              <stopPort>9999</stopPort>
              <stopKey>foo</stopKey>
              <daemon>true</daemon>
            </configuration>
         </execution>
         <execution>
            <id>stop-jetty</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>stop</goal>
            </goals>
         </execution>
       </executions>
    </plugin>
Run Code Online (Sandbox Code Playgroud)

知道是什么原因引起的吗?Thx提前.

java maven maven-jetty-plugin

5
推荐指数
1
解决办法
4736
查看次数

MavenSession没有填充

我正在尝试创建我的第一个Maven插件,为此我需要在我的Mojos中访问MavenSession.我在很多地方发现下面的代码片段应该足够了,但是我总是将mavenSession对象作为null,尽管在Maven日志中(使用我的插件的POM.xml),似乎maven会话被传递,或者至少填充 - 但不会注入MavenSession对象.

谁能告诉我我错过了什么?

谢谢!


/**
 * The Maven Session
 *
 * @required
 * @readonly
 * @parameter
 * expression="${session}"
 */
private MavenSession mavenSession;
Run Code Online (Sandbox Code Playgroud)

我还将以下内容添加到插件的POM.xml中(基于我在某处发现的注释):

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-core</artifactId>
    <version>3.2.5</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

这来自日志:

[DEBUG] Configuring mojo 'com.ofernicus.helpers:resource-helper:1.0-SNAPSHOT:iterate' with basic configurator -->
[DEBUG]   (f) session = org.apache.maven.execution.MavenSession@1a785a79
[DEBUG]   (f) mavenProject = MavenProject: com.ofernicus.consumers:resource-helper-consumer:1.0-SNAPSHOT @ C:\Users\oferlan\workspaces\Maven\PluginConsumer\resource-helper-consumer\pom.xml
Run Code Online (Sandbox Code Playgroud)

java maven-plugin maven

5
推荐指数
1
解决办法
1870
查看次数