maven聚合项目部署到tomcat上
目录
(2)修改tomcat conf路径下的server.xml文
要部署到tomcat上,所以需要先从官网上下载tomcat,tomcat官网:Apache Tomcat® - Welcome!
一.聚合项目
1.检查无误后将项目打包
2.将这四个拷贝到tomcat的webapp下
二.启动tomcat
启动tomcat要先双颊startup.bat,再去浏览器输入网址
1.双击startup.bat
2.页面访问http://localhost:8080
3.打开webapp文件夹,发现多了三个文件夹
4.点进去才有要访问的index页面
5.再进行访问
可以看到访问成功了,但是没有样式,因为访问页面加了hami-portal-1.0-SNAPSHOT,同样的CSS样式(静态资源)也要加这个路径
解决:
(1)将代码中的静态资源路径修改一下,但是麻烦
(2)修改tomcat conf路径下的server.xml文
server.xml
注意:
(1)这个里面8087是各个模块的端口号
<Connector port="8087" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
(2)docBase一定要写对!!!
path="/":代表再进行访问的时候就可以直接访问里面的资源了,不用再加hami-portal-1.0-SNAPSHOT或其他的了
<Context path="/" docBase="hami-portal-1.0-SNAPSHOT" reloadable="true" />
<Service name="Catalina">
<Connector port="8087" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="/" docBase="hami-portal-1.0-SNAPSHOT" reloadable="true" />
</Host>
</Engine>
</Service>
<Service name="Catalina">
<Connector port="8086" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="/" docBase="hami-file-1.0-SNAPSHOT" reloadable="true" />
</Host>
</Engine>
</Service>
<Service name="Catalina">
<Connector port="8085" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="/" docBase="hami_console-1.0-SNAPSHOT" reloadable="true" />
</Host>
</Engine>
</Service>
注:
core放不放在webapp下没有关系,因为在pom里他们就依赖了core,只要在本地库里有就能访问到
再进行访问就可以了
现在就能访问到了
后台:
前台:
原文地址:https://blog.csdn.net/2201_76081438/article/details/144311779
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!