这里有两个类的main需要支持,分别是:com.prl.nettydemo.telnet.TelnetServer(telnet服务端),com.prl.nettydemo.telnet.TelnetClient(telnet客户端)
,pom片断如下:
<profiles> <profile> <id>telnetServer</id> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1.1</version> <executions> <execution> <phase>test</phase> <goals> <goal>java</goal> </goals> <configuration> <mainClass>com.prl.nettydemo.telnet.TelnetServer</mainClass> <arguments> <argument>arg0</argument> <argument>arg1</argument> </arguments> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>telnetClient</id> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1.1</version> <executions> <execution> <phase>test</phase> <goals> <goal>java</goal> </goals> <configuration> <mainClass>com.prl.nettydemo.telnet.TelnetClient</mainClass> <arguments> <argument>localhost</argument> <argument>8080</argument> </arguments> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile>
argument指定了我们的运行参数;
用如下命令即可分别执行服务端和客户端:(-P后面的参数即为我们的profile的id号)
mvn test -PtelnetServer
mvn test -PtelnetClient