这里有两个类的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
本文介绍如何使用Maven配置并启动Telnet服务端及客户端。通过定义特定的profile,可以轻松地在命令行中使用mvn命令启动Telnet服务端或客户端。此配置适用于Netty框架下的Telnet应用。
976

被折叠的 条评论
为什么被折叠?



