1、eclipse内存溢出
今天解决了eclipse内存溢出的问题,运行的时候没有问题但是 会爆出一下的问题,一开始没有把他当成错误,最后果然还是有问题,下面就来描述一下解决问题的方法
Exception in thread "http-bio-8080-exec-2"
在eclipse代码的空白处点击右键,按照下图选择
然后在下图位置输入参数,这样再次运行就可以了;
-Xms256m -Xmx512m -XX:MaxNewSize=256m -XX:MaxPermSize=256m
2、oracle的链接
常用的链接语句和授权语句要准备更好
sqlplus scott/tiger@192.168.177.128:1521/orcl
//远程链接服务器的数据库
sqlplus sys/任意值 as sysdba
//本地链接超级管理员
grant SELECT ANY DICTIONARY to scott;//超级管理员的授权
配置plsql的TNS环境变量
3、ssh+Maven框架的融合
3.1 目录包的划分
划分为utils、exception、dao、service、web、parent、domain七大模块
3.2 开发的顺序:
utils模块:单独的一个子模块
domain模块:注意实体类和他的映射文件相对位置
dao模块:持久层的一些交互处理,注意配置文件只有---applicationContext-dao.xml---这一个文件内容是
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
//Spring的分层管理,有什么类写对应的bean工厂,其余的放在web层
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
<bean id="baseDao" class="com.chuantao.jk.daoImp.BaseDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
</beans>
service模块:初始化比较简单,但是要注意 pom文件继承以上两个 和 exception 三个jar包
web模块:最为复杂,需要注意的点:web.xml文件 注意顺序内容为:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<!--spring配置文件的加载的监听 器-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--2.懒加载 OpenSessionInviewFilter noSession or session is closed-->
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Shiro Security filter filter-name这个名字的值将来还会在spring中用到,不该写的不要乱写 -->
<!-- <filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> -->
<!--3.struts2核心控制器-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--CharacterEncodingFilter进行编码过滤-->
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
以及 Hibernate.cfg.xml文件内容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.Oracle10gDialect
</property>
<property name="show_sql">true</property>
<property name="format_sql">false</property>
<property name="hbm2ddl.auto">none</property>
<!-- 懒加载,配合web.xml中配置的 openSessionInViewFilter -->
<property name="hibernate.enable_lazy_load_no_trans">true</property>
<!--校验模式 JPA java persistent api-->
<property name="javax.persistence.validation.mode">none</property>
<!-- 加载映射文件-->
<mapping resource="/com/chuantao/jk/domain/Dept.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
Spring-action文件,内容
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="loginAction" class="com.chuantao.jk.web.action.LoginAction" scope="prototype"></bean>
<bean id="homeAction" class="com.chuantao.jk.web.action.HomeAction" scope="prototype"></bean>
</beans>
Struts核心配置文件 内容
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.ui.theme" value="simple"/>
<constant name="struts.devMode" value="true" />
<constant name="struts.i18n.encoding" value="UTF-8" />
<package name="default" namespace="/" extends="struts-default">
<!--全局结果视图-->
<global-results>
<result name="error">/WEB-INF/pages/error.jsp</result>
</global-results>
<!--全局异常处理-->
<global-exception-mappings>
<exception-mapping exception="cn.itcast.jk.exception.SysException" result="error"></exception-mapping>
<exception-mapping exception="java.lang.Exception" result="error"></exception-mapping>
</global-exception-mappings>
<action name="login" method="login" class="loginAction">
<result name="login">/WEB-INF/pages/sysadmin/login/login.jsp</result>
<result name="success">/WEB-INF/pages/home/fmain.jsp</result>
</action>
<action name="logout" method="logout" class="loginAction">
<result name="logout">/WEB-INF/pages/sysadmin/login/logout.jsp</result>
</action>
<action name="homeAction_*" method="{1}" class="homeAction">
<result name="fmain">/WEB-INF/pages/home/fmain.jsp</result>
<result name="title">/WEB-INF/pages/home/title.jsp</result>
<result name="toleft">/WEB-INF/pages/${moduleName}/left.jsp</result>
<result name="tomain">/WEB-INF/pages/${moduleName}/main.jsp</result>
</action>
</package>
</struts>
最后交给SpringContext.xml最终整合
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver" />
<property name="jdbcUrl" value="jdbc:oracle:thin:@192.168.177.128:1521:orcl" />
<property name="user" value="scott" />
<property name="password" value="tigger" />
</bean>
<!-- 2.sessionFactory-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:hibernate.cfg.xml"></property>
</bean>
<!--Shiro安全框架产生代理子类的方式: 使用cglib方式-->
<aop:aspectj-autoproxy proxy-target-class="true" />
<!-- 3.事务管理器-->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 4.txAdvice-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="get*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!-- 5.aop-->
<aop:config>
<aop:pointcut id="pointcut" expression="execution(* com.chuantao.jk.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
</aop:config>
<!--组装其它 配置文件-->
<import resource="classpath:applicationContext-action.xml"></import>
<import resource="classpath:applicationContext-dao.xml"></import>
<import resource="classpath:applicationContext-service.xml"></import>
</beans>
顺序还是有一些生疏,加强最后的统筹工作。
4、更好的使用作图工具推荐 PowerDesigner15.1
这个工具可以对需求任务做很好的安排,对于开发思路有不错的提升