xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
4.0.0
cn.itbluebox
dubbo-web
1.0-SNAPSHOT
<spring.version>5.1.9.RELEASE</spring.version>
<dubbo.version>2.7.4.1</dubbo.version>
<zookeeper.version>4.0.0</zookeeper.version>
javax.servlet
javax.servlet-api
3.1.0
provided
org.springframework
spring-context
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.slf4j
slf4j-api
1.7.21
org.slf4j
slf4j-log4j12
1.7.21
org.apache.dubbo
dubbo
${dubbo.version}
org.apache.curator
curator-framework
${zookeeper.version}
org.apache.curator
curator-recipes
${zookeeper.version}
org.apache.tomcat.maven
tomcat7-maven-plugin
2.1
8000
2、在dubbo-service当中引入依赖
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd”>
4.0.0
cn.itbluebox
dubbo-service
1.0-SNAPSHOT
<spring.version>5.1.9.RELEASE</spring.version>
<dubbo.version>2.7.4.1</dubbo.version>
<zookeeper.version>4.0.0</zookeeper.version>
javax.servlet
javax.servlet-api
3.1.0
provided
org.springframework
spring-context
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.slf4j
slf4j-api
1.7.21
org.slf4j
slf4j-log4j12
1.7.21
org.apache.dubbo
dubbo
${dubbo.version}
org.apache.curator
curator-framework
${zookeeper.version}
org.apache.curator
curator-recipes
${zookeeper.version}
package com.itbluebox.service;
public interface UserService {
public String sayHello();
}
package com.itbluebox.service.impl;
import com.itbluebox.service.UserService;
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl implements UserService {
@Override
public String sayHello() {
return “hello dubbo!~”;
}
}
1、创建相关的配置文件
- applicationContext.xml
<beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns:dubbo=“http://dubbo.apache.org/schema/dubbo” xmlns:context=“http://www.springframework.org/schema/context”
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package=“com.itbluebox.service”/>
- log4j.properties
DEBUG < INFO < WARN < ERROR < FATAL
Global logging configuration
log4j.rootLogger=info, stdout,file
My logging configuration…
#log4j.logger.com.tocersoft.school=DEBUG
#log4j.logger.net.sf.hibernate.cache=debug
Console output…
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p %d %C: %m%n
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=…/logs/iask.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %l %m%n
1、修改一下配置文件
war
2、创建对应的目录和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”
version=“2.5”>
contextConfigLocation
classpath*:spring/applicationContext*.xml
org.springframework.web.context.ContextLoaderListener
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring/springmvc.xml
springmvc
*.do
设置一下依赖
dubbo-web 依赖dubbo-service