- Java Transport Client (deprecated): other versions:
- Preface
- Maven Repository
- Dealing with JAR dependency conflicts
- Embedding jar with dependencies
- Deploying in JBoss EAP6 module
- Client
- Document APIs
- Search API
- Count API
- Aggregations
- Percolate API
- Query DSL
- Indexed Scripts API
- Java API Administration
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Embedding jar with dependencies
editEmbedding jar with dependencies
editIf you want to create a single jar containing your application and all dependencies, you should not
use maven-assembly-plugin
for that because it can not deal with META-INF/services
structure which is
required by Lucene jars.
Instead, you can use maven-shade-plugin
and configure it as follow:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.4.1</version> <executions> <execution> <phase>package</phase> <goals><goal>shade</goal></goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> </transformers> </configuration> </execution> </executions> </plugin>
Note that if you have a main
class you want to automatically call when running java -jar yourjar.jar
, just add
it to the transformers
:
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>org.elasticsearch.demo.Generate</mainClass> </transformer>
Was this helpful?
Thank you for your feedback.