maven-3

Exclude maven dependency for tests

谁说胖子不能爱 提交于 2019-12-28 05:56:13
问题 I have a dependency that is needed for a compilation and runtime but I want to exclude it when running tests. Is this possible? Maybe, by setting up a profile? But how do I deactivate it only for test lifecycle phase? 回答1: You could (re)configure the classpath during the test phase thanks to the maven surefire plugin. You can add classpath elements or exclude dependencies. <project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin<

Maven not including dependencies

跟風遠走 提交于 2019-12-25 14:12:23
问题 I have this in my pom.xml file: <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/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.foo.ch1</groupId> <artifactId>tutorials</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <name>tutorials</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit<

Maven Version Range - downloads all the available versions not just the latest one

隐身守侯 提交于 2019-12-25 09:12:58
问题 I have two modules: A and B. A depends from B. In the module A there is a dependency to B with the following version setting: [1.0.0,) From the B there are two versions: 1.0.0-1 and 1.0.0-2. The 1.0.0-1 is out of date, it has some missing dependencies, hence I cannot create a build from it. But the 1.0.0-2 is working fine. When I use the install for the module A I get an error that B:1.0.0-1 has a missing dependency. That's happening because the maven downloaded all the versions from the 1.0

What classpath does maven set for different goals? Can you provide a link to official docs?

孤人 提交于 2019-12-25 07:39:17
问题 To what does Maven set the classpath for different goals? My issue: I have a project that I am building in Jenkins. It gets checked out form SVN. As the next thing, a different file is checked out into workspace-root/mydir/my.properties Then, maven test is run. In the test, a class loads the file by searching it on the classpath. Why does that work? (I'm new to Jenkins and maven and am trying to figure out how the job I'm looking at works...) 回答1: Maven uses the <dependencies/> defined in

Configuration of test directories in a mavenized Android project

风流意气都作罢 提交于 2019-12-25 07:00:54
问题 I have an Android project, which uses Maven. Originally, it worked fine with Eclipse (ADT). But then I added a unit test and moved the source code from src to src/main/java directory and put my unit tests into src/test/java folder. Thereafter Eclipse started to complain about wrong package names and refuses to run/debug my unit tests. I tried to fix the problem by adding src/main/java and src/test/java to Java source path. But this didn't help, I still can't run unit tests. How can I fix this

Maven: dynamic specification of dependencies

孤者浪人 提交于 2019-12-25 06:39:37
问题 I have started to learn Maven and have the following question: I would like to dynamically specify a dependency for building maven project instead of using the dependency specified in POMs - is there a way to do that? So although I have the following dependencies specified in POM ... <dependencies> <dependency> <groupId>group</groupId> <artifactId>ProjectComponent</artifactId> <version>1.0</version> </dependency> ... I would like to specify in the build command that I want to use a different

How create file and put it in a war with Maven?

雨燕双飞 提交于 2019-12-25 04:57:06
问题 How I can create file and put it in a war with Maven when building the war? 回答1: Maven builds a war by executing the war goal of the maven-war plugin. Have a look at the configuration parameters of this goal at http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html. Basically, warSourceDirectory (defaulting to ${basedir}/src/main/webapp) contains the files that go to the war, apart from your java code and resources. Fine tune with packagingIncludes/packagingExcludes. To include file(s

ClassNotFoundException: com.ibm.mq.jms.MQConnectionFactory (Websphere MQ 7.5 + spring jms + maven tomcat 7 plugin)

橙三吉。 提交于 2019-12-25 03:39:22
问题 I am trying to create simple Webapp to demonstrate the using WMQ 7.5 in Servlet Container (tomcat). My webbap is based on standalone WMQ sample app. My standalone app works good. The testcase is also good. @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = AppConfig.class) public class MQMessageTest { /** * Message count fot test */ private static final int MESSAGE_COUNT = 25; /** * Setting Environment for getting properties */ @Autowired private Environment environment;

Maven incorrect dependancy version resolution

梦想的初衷 提交于 2019-12-25 03:22:55
问题 When including the latest Spring Hateoas Starter, Maven is downloading the incorrect Spring Hateoas. <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-hateoas</artifactId> <version>2.2.0.M1</version> </dependency> When I run the maven dependency tree I get the following: > mvn dependency:tree | grep hateoas INFO] +- org.springframework.boot:spring-boot-starter-hateoas:jar:2.2.0.M1:compile [INFO] | +- org.springframework.hateoas:spring-hateoas:jar:0.25.1

Seemingly Random Test Failure With Maven & Spring Boot 2 When A WebFluxTest Is Introduced

流过昼夜 提交于 2019-12-25 02:26:41
问题 Environment OSX 10.13.5 Java 10.0.1 2018-04-17 Apache Maven 3.5.2 Spring Boot 2.0.3.RELEASE Maven Surefire plugin 2.22.0 Issue I have a test which reliably passes: public class TransformerTest { private final MyTransformer transformer = new MyTransformerImpl(); @Rule public final OutputCapture outputCapture = new OutputCapture(); @Test public void successShouldLogSuccessMessages() { final B result = transformer.transform(new A()); outputCapture.expect(containsString("First message"));