请问s2jh如何修改mysql数据库看demo

发布于 2021-11-28 00:18:46 字数 199 浏览 931 评论 4

@S2JH 你好,想跟你请教个问题:我想在mysql数据库上演示你的prototype,如何修改数据库配置,弄了好久没有成功,能不能详细解答一下,非常的感谢。还有多项目依赖那个开发有相关资料吗,我参考一下

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

臻嫒无言 2021-11-28 14:04:32

参考:MySQL数据库配置说明

http://git.oschina.net/xautlx/s2jh/wikis/DevCfg

左岸枫 2021-11-28 12:38:35
<bean id="dataSourceSpied" class="org.apache.commons.dbcp.BasicDataSource"
			destroy-method="close">
			<property name="driverClassName" value="com.mysql.jdbc.Driver" />
			<property name="url" value="jdbc:mysql://localhost:3306/s2jh" />
			<property name="username" value="root" />
			<property name="password" value="root" />
			<!-- Connection Pooling Info -->
			<property name="initialSize" value="1" />
			<property name="maxActive" value="3" />
			<property name="minIdle" value="1" />
			<property name="maxIdle" value="5" />
			<property name="maxWait" value="30000" />
			<property name="removeAbandoned">
				<value>true</value>
			</property>
			<property name="removeAbandonedTimeout">
				<value>180</value>
			</property>
			<property name="poolPreparedStatements" value="false" />
			<property name="defaultAutoCommit" value="true" />

</bean>




改掉上面的配置,quartz改成mysql。差不多了

泪冰清 2021-11-28 12:26:34
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd"
    default-lazy-init="false">

    <beans profile="development">
        <!-- 缺省PropertyPlaceholder定义 -->
        <bean class="lab.s2jh.ctx.ExtPropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/application.properties</value>
                    <value>classpath:/application_prd.properties</value>
                </list>
            </property>
            <property name="ignoreResourceNotFound" value="true" />
            <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
        </bean>

        <!-- H2文件模式数据库,实际开发替换成其他MySQL、Oracle等数据库配置即可,注意别忘了在pom.xml中添加对应数据库驱动的依赖 -->
        <bean id="dataSourceSpied" class="org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean">
            <property name="databaseName" value="${user.dir}/h2/prototype" />
            <property name="databaseConfigurer">
                <bean class="lab.s2jh.core.dao.h2.H2EmbeddedFileDatabaseConfigurer" />
            </property>
        </bean>

        <!-- 定制log4jdbc做一些输出SQL信息的微调 -->
        <bean id="extSlf4jSpyLogDelegator" class="lab.s2jh.core.dao.log4jdbc.ExtSlf4jSpyLogDelegator" />

        <!-- 用log4jdbc对datasouce进行包裹实现完整的SQL语句跟踪 -->
        <bean id="dataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource" depends-on="extSlf4jSpyLogDelegator">
            <constructor-arg>
                <ref bean="dataSourceSpied" />
            </constructor-arg>
        </bean>

        <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"
            enabled="${jdbc.initialize.database.enable}">

            <jdbc:script location="classpath:sql/ddl/quartz/tables_h2.sql" encoding="UTF-8" />

            <jdbc:script location="classpath:sql/data/t_sys_data_dict.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_sys_menu.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_privilege.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_role.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_department.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_user.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_user_r2_role.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_sys_pub_post.sql" encoding="UTF-8" />
            
            <jdbc:script location="classpath:sql/data/biz_finance_account_subject.sql" encoding="UTF-8" />
        </jdbc:initialize-database>

        <bean id="mockDataGenerator" class="lab.s2jh.biz.util.MockDataGenerator" init-method="initializeDatabase">
            <property name="enabled" value="${jdbc.initialize.database.enable}" />
            <property name="entityManagerFactory" ref="entityManagerFactory" />
            <property name="transactionManager" ref="transactionManager" />
        </bean>

        <import resource="classpath:/service/spring*.xml" />
    </beans>

    <beans profile="production">
        <!-- 缺省PropertyPlaceholder定义 -->
        <bean class="lab.s2jh.ctx.ExtPropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/application.properties</value>
                    <value>classpath:/application_prd.properties</value>
                </list>
            </property>
            <property name="ignoreResourceNotFound" value="true" />
            <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
        </bean>

        <jee:jndi-lookup id="dataSourceSpied" jndi-name="java:comp/env/jdbc/s2jh" />

        <!-- 定制log4jdbc做一些输出SQL信息的微调 -->
        <bean id="extSlf4jSpyLogDelegator" class="lab.s2jh.core.dao.log4jdbc.ExtSlf4jSpyLogDelegator" />

        <!-- 用log4jdbc对datasouce进行包裹实现完整的SQL语句跟踪 -->
        <bean id="dataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource" depends-on="extSlf4jSpyLogDelegator">
            <constructor-arg>
                <ref bean="dataSourceSpied" />
            </constructor-arg>
        </bean>

        <jdbc:initialize-database data-source="dataSource" ignore-failures="ALL"
            enabled="${jdbc.initialize.database.enable}">

            <jdbc:script location="classpath*:sql/ddl/quartz/tables_mysql.sql" encoding="UTF-8" />

            <jdbc:script location="classpath:sql/data/t_sys_data_dict.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_sys_menu.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_privilege.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_role.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_user.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_auth_user_r2_role.sql" encoding="UTF-8" />
            <jdbc:script location="classpath:sql/data/t_sys_pub_post.sql" encoding="UTF-8" />
        </jdbc:initialize-database>

        <import resource="classpath:/service/spring*.xml" />
    </beans>

    <!-- 用于Unit Test配置 -->
    <beans profile="test">
        <!-- 缺省PropertyPlaceholder定义 -->
        <bean class="lab.s2jh.ctx.ExtPropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:/application.properties</value>
                    <value>classpath:/application-test.properties</value>
                </list>
            </property>
            <property name="ignoreResourceNotFound" value="true" />
            <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
        </bean>

        <!-- 嵌入式内存中数据库 -->
        <jdbc:embedded-database id="dataSourceSpied" type="H2">
            <jdbc:script location="classpath:sql/ddl/quartz/tables_h2.sql" encoding="UTF-8" />
        </jdbc:embedded-database>

        <bean id="dataSource" class="net.sf.log4jdbc.Log4jdbcProxyDataSource">
            <constructor-arg>
                <ref bean="dataSourceSpied" />
            </constructor-arg>
        </bean>
    </beans>
</beans>

牵你的手,一向走下去 2021-11-28 02:28:45

具体可以把异常信息发出来看看。最近在尝试在另外一个平台部署mysql版本演示。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文