未验证 提交 0edce4c0 编写于 作者: Z Zhiyu Yang 提交者: GitHub

[TD-4762]<feature>: use maven-assembly-plugins to package multi packages for jdbc demo (#6539)

* [TD-4762]<feature>: use maven-assembly-plugin package multi package for this demo

* change
上级 a50438f1
...@@ -9,11 +9,15 @@ ...@@ -9,11 +9,15 @@
<version>SNAPSHOT</version> <version>SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties>
<project.assembly.dir>src/main/resources/assembly</project.assembly.dir>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.22</version> <version>2.0.30</version>
</dependency> </dependency>
</dependencies> </dependencies>
...@@ -22,20 +26,60 @@ ...@@ -22,20 +26,60 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version> <version>3.3.0</version>
<executions>
<!-- jdbcDemo -->
<execution>
<id>JdbcDemo</id>
<configuration> <configuration>
<finalName>JdbcDemo</finalName>
<archive> <archive>
<manifest> <manifest>
<mainClass>com.taosdata.example.JDBCDemo</mainClass> <mainClass>com.taosdata.example.JdbcDemo</mainClass>
</manifest> </manifest>
</archive> </archive>
<descriptorRefs> <descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef> <descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs> </descriptorRefs>
</configuration> </configuration>
<executions> <phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
<execution> <execution>
<id>make-assembly</id> <id>JdbcRestfulDemo</id>
<configuration>
<finalName>JdbcRestfulDemo</finalName>
<archive>
<manifest>
<mainClass>com.taosdata.example.JdbcRestfulDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
<execution>
<id>SubscribeDemo</id>
<configuration>
<finalName>SubscribeDemo</finalName>
<archive>
<manifest>
<mainClass>com.taosdata.example.SubscribeDemo</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>single</goal> <goal>single</goal>
......
...@@ -11,12 +11,12 @@ Download the tdengine package on our website: ``https://www.taosdata.com/cn/all- ...@@ -11,12 +11,12 @@ Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-
## Run jdbcDemo using mvn plugin ## Run jdbcDemo using mvn plugin
run command: run command:
``` ```
mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JDBCDemo" mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo"
``` ```
and run with your customed args and run with your customed args
``` ```
mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JDBCDemo" -Dexec.args="-host [HOSTNAME]" mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -Dexec.args="-host [HOSTNAME]"
``` ```
## Compile the Demo Code and Run It ## Compile the Demo Code and Run It
......
...@@ -3,7 +3,7 @@ package com.taosdata.example; ...@@ -3,7 +3,7 @@ package com.taosdata.example;
import java.sql.*; import java.sql.*;
import java.util.Properties; import java.util.Properties;
public class JDBCDemo { public class JdbcDemo {
private static String host; private static String host;
private static final String dbName = "test"; private static final String dbName = "test";
private static final String tbName = "weather"; private static final String tbName = "weather";
...@@ -17,7 +17,7 @@ public class JDBCDemo { ...@@ -17,7 +17,7 @@ public class JDBCDemo {
if (host == null) { if (host == null) {
printHelp(); printHelp();
} }
JDBCDemo demo = new JDBCDemo(); JdbcDemo demo = new JdbcDemo();
demo.init(); demo.init();
demo.createDatabase(); demo.createDatabase();
demo.useDatabase(); demo.useDatabase();
......
...@@ -4,7 +4,7 @@ import java.sql.*; ...@@ -4,7 +4,7 @@ import java.sql.*;
import java.util.Properties; import java.util.Properties;
public class JdbcRestfulDemo { public class JdbcRestfulDemo {
private static final String host = "master"; private static final String host = "127.0.0.1";
public static void main(String[] args) { public static void main(String[] args) {
try { try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册