Java的新项目传智健康笔记(五)

 

2.2.7 health_backend                                                              

创建health_backend,子工程,打包方式为war,单独部署,存放Controller、页面等

pom.xml

xml version="1.0" encoding="UTF‐8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"          xmlns:xsi="http://www.w3.org/2001/XMLSchema‐instance"          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0                             [url]http://maven.apache.org/xsd/maven[/url]‐4.0.0.xsd">     <parent>         <artifactId>health_parentartifactId>         <groupId>com.itheimagroupId>         <version>1.0‐SNAPSHOTversion>     parent>     <modelVersion>4.0.0modelVersion>     <artifactId>health_backendartifactId>     <packaging>warpackaging>     <dependencies>         <dependency>             <groupId>com.itheimagroupId>             <artifactId>health_interfaceartifactId>             <version>1.0‐SNAPSHOTversion>         dependency>     dependencies>     <build>         <plugins>             <plugin>                 <groupId>org.apache.tomcat.mavengroupId>                 <artifactId>tomcat7‐maven‐pluginartifactId>                 <configuration>                                          <port>82port>                                          <path>/path>                 configuration>             plugin>         plugins>     build> project>

log4j.properties

### direct log messages to stdout ### log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.err log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L  ‐ %m%n

### direct messages to file mylog.log ### log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=c:\\mylog.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L ‐  %m%n

### set log levels ‐ for more verbose logging change 'info' to 'debug'  ###

log4j.rootLogger=info, stdout[/align][align=left]

 

springmvc.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:context="http://www.springframework.org/schema/context"

    xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"

    xmlns:mvc="http://www.springframework.org/schema/mvc"

    xsi:schemaLocation="http://www.springframework.org/schema/beans

                        [url]http://www.springframework.org/schema/beans/spring[/url]‐beans.xsd

                        [url]http://www.springframework.org/schema/mvc[/url]                         [url]http://www.springframework.org/schema/mvc/springmvc.xsd[/url]

                        [url]http://code.alibabatech.com/schema/dubbo[/url]

                        [url]http://code.alibabatech.com/schema/dubbo/dubbo.xsd[/url]

                        [url]http://www.springframework.org/schema/context[/url]

                        [url]http://www.springframework.org/schema/context/spring[/url]‐context.xsd">

    <mvc:annotation‐driven>

      <mvc:message‐converters register‐defaults="true">

        <bean

class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">           <property name="supportedMediaTypes" value="application/json"/>

          <property name="features">

            <list>

              <value>WriteMapNullValuevalue>

              <value>WriteDateUseDateFormatvalue>

            list>

          property>

        bean>

      mvc:message‐converters>

    mvc:annotation‐driven>

    

    <dubbo:application name="health_backend" />

    

    <dubbo:registry address="zookeeper://127.0.0.1:2181"/>

    

    <dubbo:annotation package="com.itheima.controller" />

    

        超时全局设置 10分钟

        check=false 不检查服务提供方,开发阶段建议设置为false

        check=true 启动时检查服务提供方,如果服务提供方没有启动则报错

    ‐‐>

    <dubbo:consumer timeout="600000" check="false"/>

    

    <bean id="multipartResolver"

           

class="org.springframework.web.multipart.commons.CommonsMultipartResolver ">

        <property name="maxUploadSize" value="104857600" />

        <property name="maxInMemorySize" value="4096" />

        <property name="defaultEncoding" value="UTF‐8"/>

    bean>

beans>

web.xml

<web‐app>   <display‐name>Archetype Created Web Applicationdisplay‐name>      <filter>     <filter‐name>CharacterEncodingFilterfilter‐name>     <filterclass>org.springframework.web.filter.CharacterEncodingFilterfilterclass>     <init‐param>       <param‐name>encodingparam‐name>       <param‐value>utf‐8param‐value>     init‐param>     <init‐param>       <param‐name>forceEncodingparam‐name>       <param‐value>trueparam‐value>     init‐param>   filter>   <filter‐mapping>     <filter‐name>CharacterEncodingFilterfilter‐name>     <url‐pattern>/*url‐pattern>   filter‐mapping>   <servlet>     <servlet‐name>springmvcservlet‐name>     <servletclass>org.springframework.web.servlet.DispatcherServletservlet‐class>          <init‐param>       <param‐name>contextConfigLocationparam‐name>       <param‐value>classpath:springmvc.xmlparam‐value>     init‐param>     <load‐on‐startup>1load‐on‐startup>   servlet>   <servlet‐mapping>     <servlet‐name>springmvcservlet‐name>     <url‐pattern>*.dourl‐pattern>   servlet‐mapping>

web‐app>

 

你可能感兴趣的:(JAVA)