简体   繁体   English

如何在我自己的Tomcat服务器上部署Broadleaf演示?

[英]How to deploy the broadleaf demo on my own Tomcat server?

I was able to start the Broadleaf demo application from the provided scripts adminstart.sh and startsite.sh. 我能够从提供的脚本adminstart.sh和startsite.sh启动Broadleaf演示应用程序。 I was also able to change the database to MySQl. 我还能够将数据库更改为MySQl。 However, I do not understand how to create a war that can run on my Tomcat instance. 但是,我不了解如何创建可以在Tomcat实例上运行的战争。

I see that broadleaf does things differently as compared to the common approach. 与普通方法相比,我发现阔叶树的处理方式有所不同。 Usually I put the context values into the file application-context. 通常,我将上下文值放入文件application-context中。 xml that is referred in web.xml. web.xml中引用的xml。 There is no need for modifying Tomcat context.xml. 无需修改Tomcat context.xml。 The example is 这个例子是

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring/application-context.xml</param-value>
</context-param

In the broadleaf configuration there are several context parameters 在阔叶配置中,有几个上下文参数

<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>blAdmin.root</param-value>
</context-param>

<context-param>
    <param-name>patchConfigLocation</param-name>
    <param-value>
        classpath:/bl-open-admin-contentClient-applicationContext.xml
        classpath:/bl-open-admin-contentCreator-applicationContext.xml
        classpath:/bl-admin-applicationContext.xml
        classpath:/bl-cms-contentClient-applicationContext.xml
        classpath:/bl-cms-contentCreator-applicationContext.xml
        classpath*:/blc-config/admin/bl-*-applicationContext.xml
        classpath:/applicationContext.xml
        classpath:/applicationContext-email.xml
        /WEB-INF/applicationContext-datasource.xml
        /WEB-INF/applicationContext-admin-security.xml
        /WEB-INF/applicationContext-admin-filter.xml
        /WEB-INF/applicationContext-admin.xml
    </param-value>
</context-param>

<context-param>
    <param-name>shutdownHookMethod</param-name>
    <param-value>forceFlush</param-value>
</context-param>

Plus in addition in web.xml: 加上web.xml:

<!-- Initialize spring mvc -->
<servlet>
    <servlet-name>admin</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            classpath:/applicationContext-servlet-open-admin.xml
            classpath:/applicationContext-servlet-admin.xml
            classpath:/applicationContext-servlet-cms-contentClient.xml
            classpath:/applicationContext-servlet-cms-contentCreator.xml
            classpath:/bl-menu-admin-applicationContext-servlet.xml
            classpath*:/blc-config/admin/bl-*-admin-applicationContext-servlet.xml
            /WEB-INF/applicationContext-servlet-admin.xml
        </param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

The result is that the Tomcat instance contains context.xml in the conf directory that provides database pool configuration: 结果是Tomcat实例在提供数据库池配置的conf目录中包含context.xml:

What is the best way of utilizing broadleaf in my application? 在我的应用程序中利用阔叶的最佳方法是什么?

Configuration 组态

  • Put your MySQL JDBC driver to tomcat7/lib folder 将您的MySQL JDBC驱动程序放入tomcat7 / lib文件夹
  • Open web.xml for both, site and admin modules in DemoSite 在DemoSite中为站点和管理模块打开web.xml
  • Add the following code in both web.xml 在两个web.xml中添加以下代码
<resource-ref>
    <description>WEB</description>
    <res-ref-name>jdbc/web</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

<resource-ref>
    <description>STORAGE</description>
    <res-ref-name>jdbc/storage</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

<resource-ref>
    <description>SECURE</description>
    <res-ref-name>jdbc/secure</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>
  • Open cmd prompt for windows or command shell for linux 打开Windows的cmd提示符或Linux的命令外壳
  • Navigate to your JDK_directory/bin and create keystore for SSL switching 导航到您的JDK_directory / bin并创建用于SSL切换的密钥库
keytool -genkey -alias tomcat -keyalg RSA -storepass password
  • Open Tomcat7/conf/server.xml 打开Tomcat7 / conf / server.xml
  • Add the following code to enable SSL switching, just below your default connector port 在默认的连接器端口下方添加以下代码以启用SSL切换
<Connector 
    protocol="org.apache.coyote.http11.Http11NioProtocol"
    port="8443" maxThreads="200" 
    scheme="https" secure="true" 
    SSLEnabled="true"
    keystorePass="password" 
    clientAuth="false" 
    sslProtocol="TLS" 
    />
  • Open Tomcat7/conf/tomcat-users.xml 打开Tomcat7 / conf / tomcat-users.xml
  • Add following 添加以下
<user username="tomcat" password="password" roles="manager-gui"/>
  • Populate database.properties with values for your database or 使用数据库的值填充database.properties或
  • Configure JNDI for tomcat 为tomcat配置JNDI
  • In your admin or site folder there is file target/tomcat-server-config/context.xml. 在您的admin或site文件夹中,有文件target / tomcat-server-config / context.xml。
  • Copy this file into tomcat7/conf/ 将此文件复制到tomcat7 / conf /
  • Open this file and replace the following properties with your database values 打开此文件,并将以下属性替换为数据库值
username="${database.user}" : Replace with your database username (eg. broadleaf)
password="${database.password}" : Replace with your database password
driverClassName="${database.driver}" : Replace with your database classname (eg. org.postgresql.Driver)
url="${database.url}" : Replace with your database URL with database path, port and name. (eg. jdbc:postgresql://localhost:5432/broadleaf)
  • in your IDE Start Maven project install goal of lifecycle (of entire project or each module) 在您的IDE Start Maven项目生命周期(整个项目或每个模块)的安装目标中
  • This will create wars for each module 这将为每个模块造成战争
  • Start tomcat (run startup.bat/startup.sh in ~/tomcat7/bin/ ) 启动tomcat(在〜/ tomcat7 / bin /中运行startup.bat / startup.sh)
  • Go to app manager and enter tomcat username and key that you added into tomcat-users.xml 转到应用程序管理器,然后输入您添加到tomcat-users.xml中的tomcat用户名和密钥。
  • deploy admin and site wars 部署管理员和站点之战
  • context path is url mapping (eg. /admin and /demo-site) 上下文路径是url映射(例如/ admin和/ demo-site)
  • XML configuration url is full path to your targets context.xml (eg. ~/target/tomcat-server-conf/context.xml) XML配置url是目标context.xml的完整路径(例如〜/ target / tomcat-server-conf / context.xml)
  • WAR directory is full path to your war in target directory WAR目录是目标目录中战争的完整路径

  • Don't forget to change blPU.hibernate.hbm2ddl.auto in development.properties from create to update (standalone tomcat have trouble to create tables - that's my expirience with postreSQL) 不要忘记将development.properties中的blPU.hibernate.hbm2ddl.auto从create更改为update(独立的tomcat很难创建表-这就是我对postreSQL的经验)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 broadleaf演示应用程序通过mysql连接帮助tomcat外部设置 - broadleaf demo app help tomcat external setup with mysql connectivity 使用我自己的 MySQL 服务器将我的 Flask 应用程序部署到 Heroku - Deploy my Flask app to Heroku using my own MySQL server 如何在Tomcat服务器8.0.2上部署和运行第一个JSP应用程序? - How to deploy and run first JSP application on Tomcat server 8.0.2? 如何在tomcat服务器上部署带有mysql数据库的java web应用程序 - how to deploy java web application with mysql database on tomcat server 如何实现我自己的mysql服务器接口? - How to implement my own mysql server interface? 如何将我制作的应用程序部署到服务器? - How to deploy my application that i made to server ? 如何将Grails战争部署到tomcat - How to deploy a Grails war to tomcat tomcat服务器如何部署前后端同端口? - How to run front end and back end in same port to deploy in tomcat server? 如何在基于带有mysql数据库的tomcat服务器的AWS上部署Java Spring Restful Service? - How to deploy java spring restful service on AWS based on tomcat server with mysql database? 如何将我的 xampp locahost api 项目部署到在线虚拟主机服务器 - How to deploy my xampp locahost api project to an online webhosting server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM