I created simple telegram bot on Spring Boot and I am trying to deploy it to the server. So, to do this I need to create executable jar file. I built jar using mvn clean package, but it does not work. I can't run this jar from anywhere, except project root folder. When I run it from root folder everything works fine, otherwise I get an exception. I suspect that this strange behaviour is due to errors in dependencies. I've tried a lot of things, like change spring boot maven plugin's target, change jar to war, but nothing works. Is there any ideas how I can fix it and build jar correctly? Thanks for any help.
Project pom file:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<packaging>jar</packaging>
<groupId>com.example</groupId>
<artifactId>rf3dBot</artifactId>
<version>1.0</version>
<name>rf3dBot</name>
<description>rf3dBot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.telegram</groupId>
<artifactId>telegrambots-spring-boot-starter</artifactId>
<version>5.7.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>1.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>2.6.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
build logs:
$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.example:rf3dBot >-------------------------
[INFO] Building rf3dBot 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The artifact org.slf4j:slf4j-log4j12:jar:1.7.36 has been relocated to org.slf4j:slf4j-reload4j:jar:1.7.36
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # rf3dBot ---
[INFO] Deleting C:\Users\Sergey\Desktop\rf3dBot\target
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # rf3dBot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 1 resource
[INFO] Copying 755 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # rf3dBot ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 10 source files to C:\Users\Sergey\Desktop\rf3dBot\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # rf3dBot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\Users\Sergey\Desktop\rf3dBot\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # rf3dBot ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # rf3dBot ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) # rf3dBot ---
[INFO] Building jar: C:\Users\Sergey\Desktop\rf3dBot\target\rf3dBot-1.0.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.6.4:repackage (repackage) # rf3dBot ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.204 s
[INFO] Finished at: 2022-03-26T00:22:44+03:00
[INFO] ------------------------------------------------------------------------
exception (it's not so important, because in the intellij idea application works completely fine)
try
starting your app with a specified profile.
error in image shows it gives null pointer exception in RandomMemeBuilder.
U should look this class and check what is causing null pointer execption. or post more code for this class.
Related
I would like to be able to run spring-boot:build-image and have it pull the paketobuildpack from our local Artifactory server instead of docker.io. I want the plugin to use the docker config file for my credentials and not hard code them in the pom file.
This works:
<docker>
<builderRegistry>
<username>username</username>
<password>password</password>
<url>https://artifactory.mycompany.com/v2/</url>
</builderRegistry>
</docker>
When I run mvn spring-boot:build-image, without the docker block above, I get the following error:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.2:build-image (default-cli) on project demo: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.2:build-image failed: Docker API call to 'localhost/v1.24/images/create?fromImage=artifactory.mycompany.com%2Fcommon-docker-virtual%2Fpaketobuildpacks%2Fbuilder%3Abase'
failed with status code 500 "Internal Server Error" and message "Head https://artifactory.mycompany.com/v2/common-docker-virtual/paketobuildpacks/builder/manifests/base:
unknown: Authentication is required" -> [Help 1]
My .docker/config.json has the following configuration:
{
"auths": {
"artifactory.mycompany.com": {
"auth": "**token**",
"email": "myemail#mycompany.com"
}
},
"credStore": "desktop",
"credsStore": "desktop"
}
I can successfully run docker build that uses our Artifactory successfully for other unrelated images.
My pom.xml
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.penske.architecture</groupId>
<artifactId>myapp</artifactId>
<version>1.0.0.RELEASE</version>
<name>myapp</name>
<properties>
<maven.compiler.target>14</maven.compiler.target>
<maven.compiler.source>14</maven.compiler.source>
<java.version>14</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-ldap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
<image>
<name>artifactory.mycompany.com/common-docker-virtual/library/${project.artifactId}</name>
<builder>artifactory.mycompany.com/common-docker-virtual/paketobuildpacks/builder:base</builder>
<env>
<BP_JVM_VERSION>14</BP_JVM_VERSION>
</env>
</image>
</configuration>
<executions>
<execution>
<goals>
<goal>build-image</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The full maven output
[INFO] Scanning for projects...
[INFO]
[INFO] ----------< my.group:myapp >-----------
[INFO] Building myapp 1.0.0.RELEASE
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot-maven-plugin:2.4.2:build-image (default-cli) > package # myapp >>>
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) # myapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 3 resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # myapp ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) # myapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] skip non existing resourceDirectory C:\myapp\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # myapp ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # myapp ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) # myapp ---
[INFO] Building jar: C:\myapp\target\ldap-changelog-exporter.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.2:repackage (repackage) # myapp ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] <<< spring-boot-maven-plugin:2.4.2:build-image (default-cli) < package # myapp <<<
[INFO]
[INFO]
[INFO] --- spring-boot-maven-plugin:2.4.2:build-image (default-cli) # myapp ---
[INFO] Building image 'artifactory.mycompany.com/common-docker-virtual/library/myapp:latest'
[INFO]
[INFO] > Pulling builder image 'artifactory.mycompany.com/common-docker-virtual/paketobuildpacks/builder:base' 100%
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.024 s
[INFO] Finished at: 2021-02-11T16:48:27-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.4.2:build-image (default-cli) on project myapp: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:2.4.2:build-image failed: Docker API call to 'localhost/v1.24/images/create?fromImage=artifactory.mycompany.com%2Fcommon-docker-virtual%2Fpaketobuildpacks%2Fbuilder%3Abase' failed with status code 500 "Internal Server Error" and message "Head https://artifactory.mycompany.com/v2/common-docker-virtual/paketobuildpacks/builder/manifests/base: unknown: Authentication is required" -> [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/PluginExecutionException
Process finished with exit code 1
Put credentials into settings.xml (~/.m2/settings.xml or whatever you specify by -s in mvn command) inside properties section (https://maven.apache.org/settings.html#Profiles)
and then in your pom.xml replace hardcoded values with defined variable names.
If you use environment variables (${env.something}), you can even skip settings.xml and define them from cli.
I'm using "mvn test" to run cucumber tests, but when I try to pass options on the command line with
-Dcucumber.options=..., the options are ignored and the ones specified in #CucumberOptions in the runner class are used instead. For example, if I just try to display cucumber help, it ignores it and just runs the tests:
C:\Maven\ArchCuke\untitled>mvn test -Dcucumber.options="--help"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< org.example:untitled >------------------------
[INFO] Building untitled 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # untitled ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Maven\ArchCuke\untitled\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # untitled ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # untitled ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # untitled ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Maven\ArchCuke\untitled\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # untitled ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.example.steps.CucumberTestRunner
Scenario: Add two numbers # features/arith.feature:4
Given A Calculator # org.example.steps.ArithSteps.aCalculator()
When I add 2 and 2 # org.example.steps.ArithSteps.iAddAnd(int,int)
Then I get 4 # org.example.steps.ArithSteps.iGet(int)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.253 s - in org.example.steps.CucumberTestRunner
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.815 s
[INFO] Finished at: 2020-11-05T10:51:50-08:00
[INFO] ------------------------------------------------------------------------
C:\Maven\ArchCuke\untitled>
This is my runner class
package org.example.steps;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
features = {"classpath:features"},
plugin = {"pretty"}
)
public class CucumberTestRunner {
}
and this is my pom.xml.
<?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>org.example</groupId>
<artifactId>untitled</artifactId>
<version>1.0-SNAPSHOT</version>
<name>untitled</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.version>4.13</junit.version>
<cucumber.version>6.8.0</cucumber.version>
<maven.compiler.version>3.8.1</maven.compiler.version>
<maven.surefire.version>2.22.2</maven.surefire.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<!-- Include our runner class or 'mvn test' won't work; name doesn't match default template.
See https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html -->
<configuration>
<includes>
<include>CucumberTestRunner.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
I tried version 3.0.0-M5 of the surefire plugin instead of 2.22.2, with the same results.
What am I doing wrong here?
The cucumber.options property was deprecated and removed. You have to pass each option as a single property.
mvn test -Dcucumber.filter.tags='#smoke and not #ignore'
https://github.com/cucumber/cucumber-jvm/blob/main/release-notes/v5.0.0.md#property-based-options
You should not use the system property directly in your CLI. You should deliver the system property to the surefire subprocess
mvn test "-DargLine=-Dcucumber.filter.tags='#smoke and not #ignore'"
or make a little trick in your POM and then use your original CLI:
<properties>
<argLine>-Dcucumber.filter.tags='${cucumber.filter.tags}'</argLine>
</properties>
I'm trying to learn maven and work through the Maven Getting Started Guide (https://maven.apache.org/guides/getting-started/index.html#How_do_I_add_resources_to_my_JAR). I don't get the desired folder structure with a resources folder in the main directory.
I tried all archetypes on https://maven.apache.org/guides/introduction/introduction-to-archetypes.html, but none of them have the desired folder struture
My POM-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">
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
</plugin>
</plugins>
</build>
</project>
Command to create the maven project:
mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.mycompany.app -DartifactId=my-app
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany.app:my-app >----------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # my-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\k01bagci\Desktop\maven example\my-app\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # my-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\k01bagci\Desktop\maven example\my-app\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.3:testCompile (default-testCompile) # my-app ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.357 s
[INFO] Finished at: 2019-07-04T11:29:17+02:00
[INFO] ------------------------------------------------------------------------
I have several modules that I run "mvn clean install" and have to maintain the order of them. To make my life easier and not having to change TFS or anything, I thought about creating project aggregator that will have all my sub-modules, while they know nothing about this aggregator.
My project structure:
projectaggregator
|
+- submodule1
|
+- submodule2
aggregator/pom.xml:
<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.my.package</groupId>
<artifactId>projectaggregator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Project Aggregator</name>
<modules>
<module>../submodule1</module>
<!--<module>../submodule2</module>-->
</modules>
</project>
And build fails with following error:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] submodule1
[INFO] Project Aggregator
[INFO]
[INFO] Using the MultiThreadedBuilder implementation with a thread count of 8
[INFO]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Building Project Aggregator 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] Building submodule1 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- swagger-codegen-maven-plugin:2.3.1:generate (default) # submodule1 ---
[INFO] reading from src/main/resources/yaml/decision.yaml
[INFO] reading from src/main/resources/yaml/decision.yaml
[ERROR] failed to read resource listing
java.io.FileNotFoundException: src\main\resources\yaml\decision.yaml (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
...
[INFO] No .swagger-codegen-ignore file found.
[ERROR] java.lang.RuntimeException: missing swagger input or config!
...
[INFO] --------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] submodule1 ....................................... FAILURE [ 3.983 s]
[INFO] Project Aggregator ............................... SUCCESS [ 0.003 s]
[INFO] --------------------------------------------------------------------
[INFO] BUILD FAILURE
submodule1/pom.xml:
...
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
</dependency>
...
Clearly submodule1 fails to find resources since we are running submodule1 through aggregator.
Is there any way of resolving relative path to resources without having to modify submodule1 pom file?
I faced the same issue when performing a multimodule build with swagger. Apparently a limitation with the swagger plugin when looking at paths of resources.
We can work around this by using maven variables ${project.basedir} in our swagger plugin configuration :
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.1</version>
<executions><execution>
<goals><goal>generate</goal></goals>
<phase>generate-sources</phase>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/yaml/decision.yaml</inputSpec>
</configuration>
</execution></executions>
</plugin>
Referenced from here - https://github.com/swagger-api/swagger-codegen/issues/3583
When I run mvn clean install, a JAR file is generated, not a WAR file. Am I missing something? I am running Maven 3.2.1, and I'm trying to deploy a very simple web app to Tomcat.
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<name>Cafe Iteration 1 - Sakai Hello</name>
<groupId>sakaiproject</groupId>
<artifactId>sakai-cafe-iteration1-tool</artifactId>
<version>0.1</version>
<organization>
<name>Sakai Foundation</name>
<url>http://sakaiproject.org/</url>
</organization>
<inceptionYear>2004</inceptionYear>
<properties>
<deploy.type>war</deploy.type>
</properties>
<dependencies>
<!-- Java Servlets -->
<dependency>
<groupId>servletapi</groupId>
<artifactId>servletapi</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/java</sourceDirectory>
</build>
</project>
Here is some output:
// ... etc ...
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # sakai-cafe-iteration1-tool ---
[INFO] Building jar: C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\tasklist\target\sakai-cafe-iteration1-tool-0.1.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # sakai-cafe-iteration1-tool ---
[INFO] Installing C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\tasklist\target\sakai-cafe-iteration1-tool-0.1.jar to C:\Users\BJ Peter DeLaCruz\.m2\repository\sakaiproject\sakai-cafe-iteration1-tool\0.1\sakai-cafe-iteration1-tool-0.1.jar
[INFO] Installing C:\hawaii-sakai-2.9.3\sakai-src-2.9.3\tasklist\pom.xml to C:\Users\BJ Peter DeLaCruz\.m2\repository\sakaiproject\sakai-cafe-iteration1-tool\0.1\sakai-cafe-iteration1-tool-0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
// ... etc ...
Add <packaging>war</packaging> to your POM. Typically I'd put that right under the <version>.