我正在尝试使用maven-plugin-testing-harness
以下测试用例的2.1版:
public class FooTest extends AbstractMojoTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
}
public void testSomething() throws Exception {
// todo
}
}
Run Code Online (Sandbox Code Playgroud)
测试失败了setUp()
:
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.repository.RepositorySystem
roleHint:
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:257)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:239)
at org.codehaus.plexus.PlexusTestCase.lookup(PlexusTestCase.java:206)
at org.apache.maven.plugin.testing.AbstractMojoTestCase.setUp(AbstractMojoTestCase.java:118)
at foo.FooTest.setUp(FooTest.java:54)
Run Code Online (Sandbox Code Playgroud)
这些依赖关系我在pom.xml
:
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>2.1</version>
<scope>test</scope>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我正在使用Maven-Shade-Plugin来创建一个可运行的Uber-jar.根据本页的最后一帧,可以通过使用以下方式最小化jar的大小:
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但是,此功能未考虑log4j.properties文件中声明的类.因此,例如org.apache.log4j.appender.TimeAndSizeRollingAppender
,即使它已在log4j.properties文件中声明,也不包含在Uber-jar中.
我相信我会遇到与Spring相同的问题.如果我的代码仅引用接口A并且我的Spring文件包含实现A的类B的实例化,那么B可能不会被添加到jar中,因为它不在代码中.
我怎么解决这个问题?
在构建war文件的同时,我将一组罐子从一个位置复制到战争中的文件夹中.虽然文件确实被复制了,但是我认为它们被破坏了,因为在战争之外采取的jar的相同类文件打开了调试器,而在从war文件获取后它没有打开.
这是我的战争pom.xml的一部分,我在那里复制罐子
<execution>
<id>copy-jars</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/${project.artifactId}-${buildNumber}/somefolder</outputDirectory>
<resources>
<resource>
<directory>SomeSourceDirectory</directory>
<filtering>true</filtering>
<includes>
<include>**/**</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
Run Code Online (Sandbox Code Playgroud)
SomeSourceDirectory有一些jar和一些其他文件结果是:myWar/somefolder/a.jar但是当我在调试器中打开这个jar里面的类时...我在WinZip中得到错误
Invalid compressed data to extract.
Severe Error: Compressed data is invalid
Run Code Online (Sandbox Code Playgroud)
但是,当我在原始文件夹中查看时,即在战争之外,可以查看相同的类文件.复制罐子时有错误吗?谢谢.
我想做mvn clean package tomcat7:deploy
但总是得到这个错误:tomcatManager status code:403, ReasonPhrase:Forbbiden
我的配置是下一个:
〜/ .m2目录/ settings.xml中
<servers>
<server>
<id>localhost</id>
<username>tomcat</username>
<password>s3cret</password>
</server>
</servers>
Run Code Online (Sandbox Code Playgroud)
的pom.xml
<profiles>
<profile>
<id>tomcat-localhost</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<tomcat-server>localhost</tomcat-server>
<tomcat-url>http://localhost:8080/manager/html</tomcat-url>
</properties>
</profile>
</profiles>
<build>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<server>${tomcat-server}</server>
<url>${tomcat-url}</url>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
的tomcat-users.xml中
<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
Run Code Online (Sandbox Code Playgroud)
我的错是什么?因为我没有看到它.
完成邮件错误:
[INFO] --- tomcat7-maven-plugin:2.0:deploy (default-cli) @ WebApp ---
[INFO] Deploying war to http://localhost:8080/Baskeitor
Uploading: http://localhost:8080/manager/html/deploy?path=%2FWebApp
Uploaded: http://localhost:8080/manager/html/deploy?path=%2FWebApp (7985 KB at 50215.2 KB/sec)
[INFO] tomcatManager status code:403, …
Run Code Online (Sandbox Code Playgroud) 我已经在我的机器上安装了maven.我已正确设置class-path和maven主文件夹.每次执行时mvn clean install
,都会让我异常.我也尝试删除.m2文件夹,但结果相同.
mvn -version输出
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:37+08:00)
Maven home: C:\maven-3
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: D:\jdk170_45\jre
Default locale: en_US, platform encoding: MS950
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
Run Code Online (Sandbox Code Playgroud)记录mvn -X clean install
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:37+08:00)
Maven home: C:\maven-3
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: D:\jdk170_45\jre
Default locale: en_US, platform encoding: MS950
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
[DEBUG] …
Run Code Online (Sandbox Code Playgroud)我是Maven的新手.我有一个多模块maven 2项目,具有以下结构(稍微简化):
Project (POM packaging)
|
+-- Module1 (JAR)
| |
| +-- src
| |
| +-- main
| |
| +-- java
| +-- resources
|
+-- Module2 (JAR)
| |
| ...
|
+-- Web Module (WAR)
|
...
Run Code Online (Sandbox Code Playgroud)
我已将Web模块配置为包含Maven Jetty插件.这非常适合构建生产工件.为了开发,我发现我需要调用mvn install
我更改的任何模块,然后停止jetty并调用jetty:再次运行.
如果有一种方法可以让插件直接从每个模块的目标目录中选择更改,那么效率会更高.根据jetty插件文档,似乎有这样的功能,但它似乎只适用于WAR模块.
对我来说更重要的是能够更改资源文件,而无需重新启动jetty.这是因为大多数资源都是HTML模板文件,在开发过程中设计和更新模板的效率极高,而无需重新启动以查看更改.
那么,有没有办法设置jetty插件的类路径,以包含每个JAR模块的目标/类和资源目录,而不是本地存储库中的实际JAR?
谢谢!
的Yaniv
我需要让Maven将POM文件中的版本号插入位于/WEB-INF/manifest.mf下的WAR文件中的清单中.
我该怎么做呢?我能够很容易地在使用Maven的JAR-插件的JAR文件这样的文件资料,但并不在一个WAR文件工作.
谢谢您的帮助!
你能否详细解释一下jar和jar-no-fork目标之间的区别?
我从官方网站上看到它,但我无法清楚地了解这一点.
请原谅这是一个转储问题,但我已经搜索了很多,并且无法理解如何真正阅读Maven Dependency tee.我知道这个命令用于找出依赖关系但是如何?这是mvn dependency:tree -Dverbose
我项目的结果.
[INFO] +- org.springframework:spring-core:jar:4.0.2.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] +- org.springframework:spring-web:jar:4.0.2.RELEASE:compile
[INFO] | +- (org.springframework:spring-aop:jar:4.0.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-beans:jar:4.0.2.RELEASE:compile
[INFO] | | \- (org.springframework:spring-core:jar:4.0.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:4.0.2.RELEASE:compile - omitted for duplicate)
[INFO] | \- (org.springframework:spring-core:jar:4.0.2.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-webmvc:jar:4.0.2.RELEASE:compile
[INFO] | +- (org.springframework:spring-beans:jar:4.0.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:4.0.2.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:4.0.2.RELEASE:compile - omitted for …
Run Code Online (Sandbox Code Playgroud) 我有几十个和几十个.xsd
我想自动生成代码的文件.当我尝试同时生成所有文件时,一些文件具有重复的名称.
我专注于尝试让其中的两个工作.
当我得到这两个工作时,我会解决剩下的问题.但我现在只关注其中的两个文件.我无法控制它们,它们来自供应商并遵循"标准",因此编辑它们不是出于多种原因的选择.
我正在使用它maven-jaxb2-plugin
来处理这些文件.
我添加了一个binding.xjb
文件,如mat b
我在网站上找到的答案和其他说明中的链接所示.但我得到以下错误,没有输出.
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="2.1"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation=" http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd">
<jxb:bindings schemaLocation="mac-3.4.xsd">
<jxb:schemaBindings>
<jxb:package name="my.company.mac"/>
</jxb:schemaBindings>
</jxb:bindings>
<jxb:bindings schemaLocation="mac-stylesheet-3.4.xsd">
<jxb:schemaBindings>
<jxb:package name="my.company.stylesheet"/>
</jxb:schemaBindings>
</jxb:bindings>
</jxb:bindings>
Run Code Online (Sandbox Code Playgroud)
出现以下错误
[ERROR] Error while parsing schema(s).Location [ file:/C:/Users/Jarrod%20Roberson/Projects/spa-tools/spa-lib/src/main/sc
hema/mac-stylesheet-3.4.xsd{165,33}].
org.xml.sax.SAXParseException: 'halign' is already defined
Run Code Online (Sandbox Code Playgroud)
令人不快的元素是:(还有很多其他的只是第一个发生冲突的因素)
<xsd:simpleType name="halign">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="left" />
<xsd:enumeration value="center" />
<xsd:enumeration value="right" />
</xsd:restriction>
</xsd:simpleType>
Run Code Online (Sandbox Code Playgroud)
并且在每个.xsd
文件中都是相同的,如何使用仅生成一个类或者将每个类生成到其自己的包命名空间中来解决此重复问题? …