基于DOS命令打war包
环境版本信息:win10 x64;Tomcat9.0
操作
- 将javaweb项目放到磁盘中的某个位置(例如:
F:\javaweb\demo,demo为javaweb项目),路径上不可有中文字符 - 打开命令行窗口(cmd.exe),cd切换进javaweb项目里面
cd F:\javaweb\demo - 运行代码
jar -cvf Project_name.war ./*,其中Project_name命名随意,但不可有中文字符cd F:\javaweb\demo>jar -cvf Project_name.war ./* - 成功即在窗口中显示正在添加:……(输入=……)(输出=……)(压缩了……),并在项目内自动生成war文件
Tomcat中部署war包
- 启动tomcat,进入浏览器
localhost:8080 - 点击
Manager App。提示输入用户名和密码,点击取消。 - 查看
401 Unauthorized(未授权)信息
You are not authorized to view this page. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.
For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.
<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
- 将
<role />、<user />复制到conf/tomcat-users.xml的最下面(但要在<tomcat-users> </tomcat-users里面) - 再次进入
Manager App,将username、password信息复制到用户名、密码栏中,进入Manager App - 在
WAR file to deploy部分中选择war包,点击部署,成功后即可在Applications部分看到对应的javaweb项目
运行war包对应的javaweb项目
浏览器中输入localhost:8080/刚部署的javaweb项目名,出现页面即表示成功部署
Win10下用DOS命令打包WAR并部署
2102

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



