IntelliJ IDEA使用maven实现tomcat的热部署

网友投稿 166 2023-07-27

IntelliJ IDEA使用maven实现tomcat的热部署

在tomcat的conf目录 tomcat-users.xml配置以下内容(标签内),用于部署:

 

 

 

 

启动tomcat,访问 http:ip:8080/manager 验证tomcat用户是否配置成功

在maven工程的pom.xml中配置插件

org.apache.tomcat.maven

tomcat7-maven-plugin

8080

/mvc

http://192.168.43.128:8080/manager/text

tomcat

tomcat

运行配置

点击Run-->Edit Configurations

点击+号,选择Maven ,

输入信息

Name 给运行配置取的名称

Working directory(工程目录)

Command line 命令 tomcat7:deploy 或 tomcat7:redeploy

点击确定,保存。

在Run菜单下找到刚做好的配置,运行

[INFO] Scanning for projects...

[WARNING]

[WARNING] Some problems were encountered while building the effective model for org.jstudioframework:jstudio-mvc:war:1.0-SNAPSHOT

[WARNING] 'build.plugins.plugin.version' for org.apache.tomcat.maven:tomcat7-maven-plugin is missing. @ line 91, column 21

[WARNING]

[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.

[WARNING]

[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

[WARNING]

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building jstudio-mvc 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] >>> tomcat7-maven-plugin:2.2:http://redeploy (default-cli) @ jstudio-mvc >>>

[INFO]

[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ jstudio-mvc ---

[debug] execute contextualize

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] Copying 5 resources

[INFO]

[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ jstudio-mvc ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ jstudio-mvc ---

[debug] execute contextualize

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory E:\JstudioProject1\JstudioMvc\src\test\resources

[INFO]

[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ jstudio-mvc ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- maven-surefire-plugin:2.14:test (default-test) @ jstudio-mvc ---

[INFO] Tests are skipped.

[INFO]

[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ jstudio-mvc ---

[INFO] Packaging webapp

[INFO] Assembling webapp [jstudio-mvc] in [E:\JstudioProject1\JstudioMvc\target\jstudio-mvc-1.0-SNAPSHOT]

[INFO] Processing war project

[INFO] Copying webapp resources [E:\JstudioProject1\JstudioMvc\src\main\webapp]

[INFO] Webapp assembled in [177 msecs]

[INFO] Building war: E:\JstudioProject1\JstudioMvc\target\jstudio-mvc-1.0-SNAPSHOT.war

[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored

(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')

[INFO]

[INFO] <<< tomcat7-maven-plugin:2.2:redeploy (default-cli) @ jstudio-mvc <<<

[INFO]

[INFO] --- tomcat7-maven-plugin:2.2:redeploy (default-cli) @ jstudio-mvc ---

[INFO] Deploying war to http://192.168.43.128:8080/mvc

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://slf4j.org/codes.html#StaticLoggerBinder for further details.

Uploading: http://192.168.43.128:8080/manager/text/deploy?path=%2Fmvc&update=true

Uploaded: http://192.168.43.128:8080/manager/text/deploy?path=%2Fmvc&update=true (7445 KB at 7083.3 KB/sec)

[INFO] tomcatManager status code:200, ReasonPhrase:OK

[INFO] OK - Deployed application at context path /mvc

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 14.720s

[INFO] Finished at: Sun Jul 23 19:35:01 CST 2017

[INFO] FinalUdcNi Memory: 15M/322M

[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

发布成功。

在tomcat的manager可以看到新发布的应用。

方法2:

这几个标红的菜单都能远程发布

启动tomcat,访问 http:ip:8080/manager 验证tomcat用户是否配置成功

在maven工程的pom.xml中配置插件

org.apache.tomcat.maven

tomcat7-maven-plugin

8080

/mvc

http://192.168.43.128:8080/manager/text

tomcat

tomcat

运行配置

点击Run-->Edit Configurations

点击+号,选择Maven ,

输入信息

Name 给运行配置取的名称

Working directory(工程目录)

Command line 命令 tomcat7:deploy 或 tomcat7:redeploy

点击确定,保存。

在Run菜单下找到刚做好的配置,运行

[INFO] Scanning for projects...

[WARNING]

[WARNING] Some problems were encountered while building the effective model for org.jstudioframework:jstudio-mvc:war:1.0-SNAPSHOT

[WARNING] 'build.plugins.plugin.version' for org.apache.tomcat.maven:tomcat7-maven-plugin is missing. @ line 91, column 21

[WARNING]

[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.

[WARNING]

[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

[WARNING]

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building jstudio-mvc 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] >>> tomcat7-maven-plugin:2.2:http://redeploy (default-cli) @ jstudio-mvc >>>

[INFO]

[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ jstudio-mvc ---

[debug] execute contextualize

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] Copying 5 resources

[INFO]

[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ jstudio-mvc ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ jstudio-mvc ---

[debug] execute contextualize

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory E:\JstudioProject1\JstudioMvc\src\test\resources

[INFO]

[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ jstudio-mvc ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- maven-surefire-plugin:2.14:test (default-test) @ jstudio-mvc ---

[INFO] Tests are skipped.

[INFO]

[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ jstudio-mvc ---

[INFO] Packaging webapp

[INFO] Assembling webapp [jstudio-mvc] in [E:\JstudioProject1\JstudioMvc\target\jstudio-mvc-1.0-SNAPSHOT]

[INFO] Processing war project

[INFO] Copying webapp resources [E:\JstudioProject1\JstudioMvc\src\main\webapp]

[INFO] Webapp assembled in [177 msecs]

[INFO] Building war: E:\JstudioProject1\JstudioMvc\target\jstudio-mvc-1.0-SNAPSHOT.war

[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored

(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')

[INFO]

[INFO] <<< tomcat7-maven-plugin:2.2:redeploy (default-cli) @ jstudio-mvc <<<

[INFO]

[INFO] --- tomcat7-maven-plugin:2.2:redeploy (default-cli) @ jstudio-mvc ---

[INFO] Deploying war to http://192.168.43.128:8080/mvc

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://slf4j.org/codes.html#StaticLoggerBinder for further details.

Uploading: http://192.168.43.128:8080/manager/text/deploy?path=%2Fmvc&update=true

Uploaded: http://192.168.43.128:8080/manager/text/deploy?path=%2Fmvc&update=true (7445 KB at 7083.3 KB/sec)

[INFO] tomcatManager status code:200, ReasonPhrase:OK

[INFO] OK - Deployed application at context path /mvc

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 14.720s

[INFO] Finished at: Sun Jul 23 19:35:01 CST 2017

[INFO] FinalUdcNi Memory: 15M/322M

[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

发布成功。

在tomcat的manager可以看到新发布的应用。

方法2:

这几个标红的菜单都能远程发布

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Java实现的打地鼠小游戏完整示例【附源码下载】
下一篇:Java使用jdbc连接MySQL数据库实例分析
相关文章

 发表评论

暂时没有评论,来抢沙发吧~