Intellij is great, but its integration with maven still needs some work.
Here are some steps to create a jar from within Intellij Idea (Community 2017)
Continue reading Maven Jar within Intellij
Intellij is great, but its integration with maven still needs some work.
Here are some steps to create a jar from within Intellij Idea (Community 2017)
Continue reading Maven Jar within Intellij
The desired requirements are the following:
To address the requirements above we have to do the following steps:
To load the properties, we can use the following code:
Properties prop = new Properties(); prop.load(getClass().getResourceAsStream("/config.properties"));
Example of the pom.xml:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.7</version> <executions> <execution> <id>copy-resources</id> <phase>install</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/target</outputDirectory> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> </includes> </resource> </resources> </configuration> </execution> </executions> </plugin> <plugin> <!-- Build an executable JAR --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>3.0.2</version> <configuration> <excludes> <exclude>**/*.properties</exclude> </excludes> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>com.blabla.MyMainClass</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build>
A maven project in Intellij requires additional steps.
For more information read this post
Sample dependencies for google maps in pom.xml:
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.google.maps</groupId> <artifactId>google-maps-services</artifactId> <version>0.1.20</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.6.2</version> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.2.4</version> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>3.7.0</version> </dependency> </dependencies>
Add the following dependency to pom.xml:
<dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>3.7.0</version> </dependency>
Add the following dependency to pom.xml:
(may add newer versions than 1.6.2)
<dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.6.2</version> </dependency>
Reference: