https://reqbin.com/req/java/h4rnefmw/post-json-with-bearer-token-authorization-header
Thursday, March 25, 2021
Wednesday, March 24, 2021
Java Client to do a HTTP post
Had so much trouble to do this on a J2EE 6 using Jersey 1 and Apache HTTPClient.
Finally resolved using pure java.io classes:
https://gist.github.com/dnetix/db23658cb308a0f2ac1b09f2ddb726d3
Monday, March 22, 2021
Dependency management in Maven
Interesting:
https://blogs.oracle.com/developers/mastering-maven-dependency-exclusions
Using Maven to generate "fat" jars or "uber" jars
This one worked for me:
http://tutorials.jenkov.com/maven/maven-build-fat-jar.html
Here are other ways to do it:
https://mkyong.com/maven/how-to-create-a-jar-file-with-maven/
Remember to put the xml outside of pluginManagement
https://stackoverflow.com/questions/33261354/maven-copy-dependecies-not-working
If you have some jars referenced as external jars, you can try this: (didn't work for me)
https://programmersought.com/article/90075878511/
Some useful background info:
https://imagej.net/Uber-JAR
What works for me:
<build>
<finalName>icommogateway</finalName>
<pluginManagement>
<!-- lock down plugins versions to avoid using Maven defaults (may be
moved to parent pom) -->
</pluginManagement>
<plugins>
<!-- download source code in Eclipse, best practice -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<dependencySets>
<dependencySet>
<excludes>
<exclude>log4j:log4j</exclude>
</excludes>
</dependencySet>
</dependencySets>
</configuration>
</plugin>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArgs>
<!-- The parameter name and the parameter value appear in pairs, that
is, the first is the name, and the second is the value -->
<arg>-extdirs</arg>
<arg>M:/Development/Unica/Interact/912/interact.jar</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
To exclude some jars:
https://stackoverflow.com/questions/42412964/maven-depenency-plugin-copy-dependencies-exclude-single-artifact
https://github.com/albertattard/how-to-exclude-dependencies-from-maven-assembly-plugin/blob/master/pom.xml
https://blog.csdn.net/yh_zeng2/article/details/82859914