Git

2018-11-20  本文已影响5人  sunboximeng

工作区、暂存区、本地仓库、远程仓库(github、码云)

工作流程:

查看日志(提交历史):

利用SSH连接远程仓库:

分支管理(不同的时间线)

IDEA集成Git

现在已经利用可视化界面把代码从远程仓库拉下来了。如何用idea打开从而进行编辑?应该是直接导入吧。

war包结构

Tomcat怎么样解析这个war包?
Tomcat也是一个容器,通过扫描web.xml创建对象。

包结构

包的运行

配置文件内容

学框架就是学他的注解和xml配置。spring-security也是如此,不过多个接口要实现。

  1. db.properties或者redis.properties

    • jdbc.driver=
    • jdbc.url=
    • jdbc.username=
    • jdbc.password=
  2. 与dao接口对应的mapper.xml。他们的包名要一致。
    可以使用纯注解的方式取消掉这个xml。它里面写的就是sql语句和数据封装方式,可以直接写在接口上。但是动态SQL就没办法写了吧?

  3. spring的配置文件
    扫描包,mysql、redis的配置。

    • 包扫描:service、dao
      <context:component-scan base-package="com.sina.service;com.sina.dao"></context:component-scan>

    • 扫描dao接口
      <bean id="mapperScanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
      <property name="basePackage" value=""/>
      </bean>

    • 加载数据库连接信息
      <context:property-placeholder location="classpath:db.properties"/>

    • 数据库连接池(dbcp、c3p0、druid)
      <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
      <property name="driverClass" value="com.mysql.jdbc.Driver" />
      <property name="jdbcUrl" value="jdbc:mysql:///springdb" />
      <property name="user" value="${jdbc.username}" />
      <property name="password" value="root" />
      </bean>

    • 配置spring框架的事务管理。并没有使用mybatis的。
      <--事务管理器-->
      <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager" id="transactionManager">
      <property name="dataSource" ref="dataSource"></property>
      </bean>
      <tx:annotation-driven transaction-manager="transactionManager"/>

    • Spring整合Mybatis框架
      <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />

      <--pageHelper分页插件-->
      <property name="plugins">
      <array>
      <bean class="com.github.pagehelper.PageInterceptor">
      <property name="properties">
      <props>
      <--不同数据库的分页方法不一样-->
      <prop key="helperDialect">oracle</prop>
      <--分页合理化参数,防止页码越界-->
      <prop key="reasonable">true</prop>
      </props>
      </property>
      </bean>
      </array>
      </property>

    </bean>

    • AOP的配置好像可以使用注解。
  4. springMVC的配置文件

    • 包扫描:controller
      <context:component-scan base-package=""></context:component-scan>

    • 开启对SpringMVC对注解的支持
      <mvc:annotation-driven/>

    • 视图解析器,jsp开发的时候用。
      <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <-- JSP文件所在的目录 -->
      <property name="prefix" value="/WEB-INF/pages/"/>
      <property name="suffix" value=".jsp"/>
      </bean>

    • 静态资源不拦截
      如果将DispatcherServlet请求映射配置为"/",则Spring MVC将捕获Web容器所有的请求,包括静态资源的请求,Spring MVC会将它们当成一个普通请求处理,因此找不到对应处理器将导致错误。
      如何让Spring框架能够捕获所有URL的请求,同时又将静态资源的请求转由Web容器处理,是可将DispatcherServlet的请求映射配置为"/"的前提。
      <mvc:resources location="/css/" mapping="/css/" />
      <mvc:resources location="/images/" mapping="/images/
      " />
      <mvc:resources location="/js/" mapping="/js/**" />

  5. web.xml
    5.1 service、dao层
    配置了一个listener
    <-- 加载spring配置文件,文件路径加classpath前缀 -->
    <context-param>

     <param-name>contextConfigLocation</param-name>
     <param-value>classpath*:spring/applicationContext*.xml</param-value>
    

    </context-param>
    <listener>

     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    

    </listener>
    5.2 web层:
    配置了servlet、filter。不仅需要配置类名用于反射,还需要配置拦截路径!

    • controller层要解决编码问题,所以配置一个filter

    <filter>

     <filter-name>CharacterEncodingFilter</filter-name>
     <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
     <init-param>
         <param-name>encoding</param-name>
         <param-value>utf-8</param-value>
     </init-param>
     <init-param>  
         <param-name>forceEncoding</param-name>  
         <param-value>true</param-value>  
     </init-param>  
    

    </filter>
    <filter-mapping>

     <filter-name>CharacterEncodingFilter</filter-name>
     <url-pattern>/*</url-pattern>
    

    </filter-mapping>

    • 加载springMVC的配置文件及前端控制器

    <servlet>

    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <指定加载的配置文件 ,通过参数contextConfigLocation加载>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:spring/springmvc.xml</param-value>
    </init-param>
    

    </servlet>

    <servlet-mapping>

    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.do</url-pattern>
    

    </servlet-mapping>

    • spring security
      <--spring security-->
      <-- 加载spring security的配置文件 -->

    <context-param>

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

    </context-param>

    <listener>

     <listener-class>
         org.springframework.web.context.ContextLoaderListener
     </listener-class>
    

    </listener>
    <-- spring security用到的过滤器 -->
    <filter>

     <filter-name>springSecurityFilterChain</filter-name>
     <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    

    </filter>
    <filter-mapping>

     <filter-name>springSecurityFilterChain</filter-name>
     <url-pattern>/*</url-pattern>
    

    </filter-mapping>

上一篇下一篇

猜你喜欢

热点阅读