• 2015年传智播客JavaEE 第168期就业班视频教程11-导入配置文件


    资源文件放在Source Folder目录下面,这个目录同样会编译到classes目录下

    web.xml的

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

    在服务器启动的同时加载Spring的ApplicationContext对象到ServletContext范围,回头你到处都可以用了。这句话简单的意思是在服务器启动的时候把Spring环境启动起来。

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

    这句话是配置你的Spring读哪个配置文件的。

    <filter>
    <filter-name>openSessionInView</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    </filter>

    每次它都是延迟加载,而且延迟加载的东西都能得到。

    <filter-mapping>
    <filter-name>openSessionInView</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    这是openSessionInView的过滤器,不说了。

    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    这是struts2的核心过滤器。

    配置文件中openSessionInView和struts2是有顺序之分的。openSessionInView必须写在struts2之前。openSessionInView是延迟加载,用到再说吧。

    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    这是struts 2的过滤器不说了。

    web.xml文件解释过了。

    下面解释struts2

    <struts>   //这是struts 的根
    <constant name="struts.devMode" value="true" />   开发模式开启
    <constant name="struts.ui.theme" value="simple" />
    <package name="default" namespace="/" extends="struts-default">

    </package>
    </struts>

    你自己写的东西难道依赖编译器帮你检验吗?编译环境只是帮你做格式检验。

     启动服务器报错

    Caused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:cn/itcast/invoice/**/vo/*Model.hbm.xml]: class path resource [cn/itcast/invoice/] cannot be resolved to URL because it does not exist
    at org.springframework.core.io.support.ResourceArrayPropertyEditor.setAsText(ResourceArrayPropertyEditor.java:135)
    at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:452)
    at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:424)
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:181)
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:450)
    ... 41 more
    2017-1-31 19:51:01 org.apache.catalina.core.StandardContext startInternal

    你想用

    <property name="mappingLocations">
    <value>classpath:cn/itcast/invoice/**/vo/*Model.hbm.xml</value>
    </property>

    这个格式必须得保证前面的那个包cn/itcast/invoice是存在的。后面既然你写**就意味着有可能有有可能没有。如果删掉cn/itcast/invoice扫描速度太慢了。所以加上cn.itcast.invoice包吧。

     仅仅是加上这个包cn.itcast.invoice服务器启动的时候就不报错了。

    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Server version: Apache Tomcat/7.0.75
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Server built: Jan 18 2017 20:54:42 UTC
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Server number: 7.0.75.0
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: OS Name: Windows Vista
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: OS Version: 6.1
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Architecture: amd64
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Java Home: C:UsershongZhenhuaAppDataLocalMyEclipseCommoninarycom.sun.java.jdk.win32.x86_64_1.6.0.013jre
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: JVM Version: 1.6.0_13-b03
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: JVM Vendor: Sun Microsystems Inc.
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: CATALINA_BASE: F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: CATALINA_HOME: F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Dcatalina.home=F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Dcatalina.base=F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Djava.endorsed.dirs=F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75/common/endorsed
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Djava.io.tmpdir=F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75 emp
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Djava.library.path=C:UsershongZhenhuaAppDataLocalMyEclipseCommoninarycom.sun.java.jdk.win32.x86_64_1.6.0.013in;F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75in
    2017-1-31 19:57:25 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Dsun.io.useCanonCaches=false
    2017-1-31 19:57:25 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    信息: Loaded APR based Apache Tomcat Native library 1.2.10 using APR version 1.5.2.
    2017-1-31 19:57:25 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
    2017-1-31 19:57:26 org.apache.catalina.core.AprLifecycleListener initializeSSL
    信息: OpenSSL successfully initialized (OpenSSL 1.0.2j 26 Sep 2016)
    2017-1-31 19:57:26 org.apache.coyote.AbstractProtocol init
    信息: Initializing ProtocolHandler ["http-apr-8080"]
    2017-1-31 19:57:26 org.apache.coyote.AbstractProtocol init
    信息: Initializing ProtocolHandler ["ajp-apr-8009"]
    2017-1-31 19:57:26 org.apache.catalina.startup.Catalina load
    信息: Initialization processed in 1990 ms
    2017-1-31 19:57:26 org.apache.catalina.core.StandardService startInternal
    信息: Starting service Catalina
    2017-1-31 19:57:26 org.apache.catalina.core.StandardEngine startInternal
    信息: Starting Servlet Engine: Apache Tomcat/7.0.75
    2017-1-31 19:57:26 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deploying web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsdocs
    2017-1-31 19:57:27 org.apache.tomcat.websocket.server.WsSci onStartup
    信息: JSR 356 WebSocket (Java WebSocket 1.1) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available.
    2017-1-31 19:57:27 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deployment of web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsdocs has finished in 689 ms
    2017-1-31 19:57:27 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deploying web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsERP
    2017-1-31 19:57:31 org.apache.catalina.startup.TldConfig execute
    信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    2017-1-31 19:57:31 org.apache.catalina.core.ApplicationContext log
    信息: No Spring WebApplicationInitializer types detected on classpath
    2017-1-31 19:57:31 org.apache.catalina.core.ApplicationContext log
    信息: Initializing Spring root WebApplicationContext
    2017-1-31 19:57:36 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deployment of web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsERP has finished in 9,624 ms
    2017-1-31 19:57:36 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deploying web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsexamples
    2017-1-31 19:57:37 org.apache.catalina.core.ApplicationContext log
    信息: ContextListener: contextInitialized()
    2017-1-31 19:57:37 org.apache.catalina.core.ApplicationContext log
    信息: SessionListener: contextInitialized()
    2017-1-31 19:57:37 org.apache.catalina.core.ApplicationContext log
    信息: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@758c3b7')
    2017-1-31 19:57:37 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deployment of web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsexamples has finished in 579 ms
    2017-1-31 19:57:37 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deploying web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappshost-manager
    2017-1-31 19:57:37 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deployment of web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappshost-manager has finished in 132 ms
    2017-1-31 19:57:37 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deploying web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsmanager
    2017-1-31 19:57:37 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deployment of web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsmanager has finished in 147 ms
    2017-1-31 19:57:37 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deploying web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsROOT
    2017-1-31 19:57:37 org.apache.catalina.startup.HostConfig deployDirectory
    信息: Deployment of web application directory F:apache-tomcat-7.0.75-windows-x64apache-tomcat-7.0.75webappsROOT has finished in 114 ms
    2017-1-31 19:57:37 org.apache.coyote.AbstractProtocol start
    信息: Starting ProtocolHandler ["http-apr-8080"]
    2017-1-31 19:57:37 org.apache.coyote.AbstractProtocol start
    信息: Starting ProtocolHandler ["ajp-apr-8009"]
    2017-1-31 19:57:37 org.apache.catalina.startup.Catalina start
    信息: Server startup in 11455 ms

  • 相关阅读:
    Handbook of Document Image Processing and Recognition文档图像处理与识别手册 前言&目录
    An Overview of Symbol Recognition符号识别综述
    Resnet
    python detect.py
    pytorch训练模型
    如何有效使用Pretrained Models
    SOLID原则 【转】
    vi编辑器
    linux基础知识 【转】
    linux 常用命令1【转】
  • 原文地址:https://www.cnblogs.com/ZHONGZHENHUA/p/6358786.html
Copyright © 2020-2023  润新知