1.先maven install一次聚合工程taotao-manager,在本地maven仓库生成一把taotao-manager下面的4个子工程。
2.先启动taotao-manager-web,可能会报如下错,不过没关系。接着启动taotao-manager
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ taotao-manager-service --- [INFO] Running war on http://localhost:8080/ [INFO] Creating Tomcat server configuration at D:\workspace\work_1\taotao-manager\taotao-manager-service\target\tomcat [INFO] create webapp with contextPath: 四月 06, 2020 1:19:08 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-bio-8080"] 四月 06, 2020 1:19:09 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service Tomcat 四月 06, 2020 1:19:09 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.47 四月 06, 2020 1:19:12 下午 org.apache.catalina.core.ApplicationContext log 信息: No Spring WebApplicationInitializer types detected on classpath 四月 06, 2020 1:19:12 下午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 2020-04-06 13:19:35,666 [localhost-startStop-1-SendThread(192.168.25.128:2181)] [org.apache.zookeeper.ClientCnxn]-[WARN] Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: Connection timed out: no further information at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141) 2020-04-06 13:19:57,774 [localhost-startStop-1-SendThread(192.168.25.128:2181)] [org.apache.zookeeper.ClientCnxn]-[WARN] Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: Connection timed out: no further information at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141) 2020-04-06 13:20:19,883 [localhost-startStop-1-SendThread(192.168.25.128:2181)] [org.apache.zookeeper.ClientCnxn]-[WARN] Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect java.net.ConnectException: Connection timed out: no further information at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
3.常见报错
报错原因是下面这里没有找到TestMapper.xml
解决办法是在taotao-manager-dao下的个pom.xml里加上一个插件配置
配置插件后要重新maven install一次,只重新安装taotao-manager-dao子工程就可以了。
特别注意:如果上面的taotao-manager-dao下的src/main/resources/下有文件的话,加插件配置时,紧跟之前的插件配置,还需要加上如下配置(要拷贝哪些文件加在include里),不过我们这里src/main/resources/下还没有文件,所以不用加:
另一种解决该报错的办法是,在src/main/resources下再建一个目录com/taotao/mapper/ ,然后把配置文件TestMapper.xml放进新新建的目录。这是因为当没有配置插件时,默认复制的是src/main/resources目录下的文件。
4.测试成功如下