文档章节

dubbo提供者打包,解决jar不能正常运行(不能注册到注册中心)

卖女孩的小火柴
 卖女孩的小火柴
发布于 2017/02/09 09:34
字数 1037
阅读 148
收藏 0

这几天打包发布dubbo提供者,出现了各种问题.

今天记录的是直接在Eclispe是运行Main方法时正常使用服务.打包成jar在服务运行时不能正常使用问题.

我写的Main方法:

public class BannerProvider {

    public static void main(String[] args) {
        com.alibaba.dubbo.container.Main.main(args);
    }
    
}


查找了几天,翻了N文档.后来死心了..一行一行看看控制台的每一行log找到了解决方案(发现自己以前老是说别人不看控制台,我现在也懒了不想去看控制台信息..看到得好好反省反省了)

log4j:WARN No appenders could be found for logger (com.alibaba.dubbo.common.logger.LoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/provider/hequ-banner/lib/logback-classic-1.0.6.jar!/org/slf4j/impl/StaticLoggerBin
der.class]
SLF4J: Found binding in [jar:file:/D:/provider/hequ-banner/lib/slf4j-log4j12-1.6.2.jar!/org/slf4j/impl/StaticLoggerBinde
r.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
15:17:39.071 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search
 precedence
15:17:39.078 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest searc
h precedence
15:17:39.078 [main] DEBUG o.s.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [syste
mProperties,systemEnvironment]
15:17:39.084 [main] INFO  o.s.c.s.ClassPathXmlApplicationContext - Refreshing org.springframework.context.support.ClassP
athXmlApplicationContext@58027738: startup date [Mon May 25 15:17:39 CST 2015]; root of context hierarchy
15:17:39.136 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search
 precedence
15:17:39.137 [main] DEBUG o.s.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest searc
h precedence
15:17:39.138 [main] DEBUG o.s.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [syste
mProperties,systemEnvironment]
15:17:39.149 [main] DEBUG o.s.c.i.s.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:META-INF
/spring/*.xml] to resources []
15:17:39.150 [main] DEBUG o.s.b.f.xml.XmlBeanDefinitionReader - Loaded 0 bean definitions from location pattern [classpa
th*:META-INF/spring/*.xml]
15:17:39.151 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Bean factory for org.springframework.context.support.
ClassPathXmlApplicationContext@58027738: org.springframework.beans.factory.support.DefaultListableBeanFactory@39376b96:
defining beans []; root of factory hierarchy
15:17:39.177 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Unable to locate MessageSource with name 'messageSour
ce': using default [org.springframework.context.support.DelegatingMessageSource@278fea01]
15:17:39.182 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Unable to locate ApplicationEventMulticaster with nam
e 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@75a4
72e9]
15:17:39.183 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.bea
ns.factory.support.DefaultListableBeanFactory@39376b96: defining beans []; root of factory hierarchy
15:17:39.186 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Unable to locate LifecycleProcessor with name 'lifecy
cleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@5c207889]
15:17:39.187 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleP
rocessor'
15:17:39.191 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain'
 in [systemProperties]
15:17:39.191 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain'
 in [systemEnvironment]
15:17:39.191 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'spring.liveBeansView.mbeanDomain
' in any property source. Returning [null]
15:17:39.192 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleP
rocessor'
[2015-05-25 15:17:39] Dubbo service server started!
这个是直接运行jar包控制台所输出的信息.

其中日志显示加载到0个配置信息. 

Loaded 0 bean definitions from location pattern [classpath*:META-INF/spring/*.xml]

记得以前运行dubbo的demo时是正常的.

这次重新去看了dubbo的打包配置.


=================

解决方案

=================


再pom.xml中添加了这几行

<build>
		<plugins>
			<plugin>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>unpack</id>
						<phase>package</phase>
						<goals>
							<goal>unpack</goal>
						</goals>
						<configuration>
							<artifactItems>
								<artifactItem>
									<groupId>com.alibaba</groupId>
									<artifactId>dubbo</artifactId>
									<version>2.5.3</version>
									<outputDirectory>${project.build.directory}/dubbo</outputDirectory>
									<includes>META-INF/assembly/**</includes>
								</artifactItem>
							</artifactItems>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptor>src/main/assembly/assembly.xml</descriptor>
                </configuration>
                <executions>
					<execution>
						<id>make-assembly</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
					</execution>
				</executions>
            </plugin>
		</plugins>
	</build>

还需要在添加一个xml src/main/assembly/assembly.xml,一开始我是直接复制了dubbo下的.但是本人有强迫症把文件改了.你可以自己去下载原来的 dubbo原来的点这下载

PS:为了修改这个我还去apache查看了Assembly怎么配置(主要是添加了单个文件的拷贝)  官方文档


<!--
 - Copyright 1999-2011 Alibaba Group.
 -  
 - Licensed under the Apache License, Version 2.0 (the "License");
 - you may not use this file except in compliance with the License.
 - You may obtain a copy of the License at
 -  
 -      http://www.apache.org/licenses/LICENSE-2.0
 -  
 - Unless required by applicable law or agreed to in writing, software
 - distributed under the License is distributed on an "AS IS" BASIS,
 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 - See the License for the specific language governing permissions and
 - limitations under the License.
-->
<assembly>
	<id>assembly</id>
	<formats>
		<format>tar.gz</format>
	</formats>
	<includeBaseDirectory>true</includeBaseDirectory>
	<fileSets>
		<fileSet>
			<directory>${project.build.directory}/dubbo/META-INF/assembly/bin</directory>
			<outputDirectory>bin</outputDirectory>
			<fileMode>0755</fileMode>
		</fileSet>
		<fileSet>
			<directory>src/main/assembly/conf</directory>
			<outputDirectory>conf</outputDirectory>
			<fileMode>0644</fileMode>
		</fileSet>
	</fileSets>
	<files>
		<file>
			<source>src/main/resources/applicationContext.xml</source>
			<outputDirectory>conf</outputDirectory>
			<fileMode>0644</fileMode>
		</file>
		<file>
			<source>src/main/resources/dubbo.properties</source>
			<outputDirectory>conf</outputDirectory>
			<fileMode>0644</fileMode>
		</file>
		<file>
			<source>src/main/resources/hequ.properties</source>
			<outputDirectory>conf</outputDirectory>
			<fileMode>0644</fileMode>
		</file>
	</files>
	
	<dependencySets>
		<dependencySet>
			<outputDirectory>lib</outputDirectory>
		</dependencySet>
	</dependencySets>
</assembly>

重新打包 在target下生成了hequ-banner-provide-0.0.1-assembly.tar.gz 解压重新在bin正面运行对应有脚本.程序成功运行


本文转载自:http://blog.csdn.net/vispin/article/details/45969883

卖女孩的小火柴

卖女孩的小火柴

粉丝 3
博文 25
码字总数 124
作品 0
厦门
其他
私信 提问
Dubbo与Zookeeper、SpringMVC整合和使用

互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,Dubbo是一个分布式服务框架,在这种情况下诞生的。现在核心业务抽取出来,...

wangrikui
2016/03/30
926
0
[置顶] Java集群优化——dubbo+zookeeper构建高可用分布式集群

们讨论过Nginx+tomcat组成的集群,这已经是非常灵活的集群技术,但是当我们的系统遇到更大的瓶颈,全部应用的单点服务器已经不能满足我们的需求,这时,我们要考虑另外一种,我们熟悉的内容,...

梵蒂冈考虑过
2016/08/09
134
1
Dubbo面试20问!这些题你都遇到过吗?

作者:Dean Wang https://deanwang1943.github.io/bugs/2018/10/05/面试/饿了么/dubbo 面试题/ 1、dubbo是什么 dubbo是一个分布式框架,远程服务调用的分布式框架,其核心部分包含: 集群容错...

安小乐
06/10
78
0
dubbo 面试18问 JAVA葵花宝典 今天

dubbo 面试18问 dubbo是什么 dubbo是一个分布式框架,远程服务调用的分布式框架,其核心部分包含: 集群容错:提供基于接口方法的透明远程过程调用,包括多协议支持,以及软负载均衡,失败容...

DemonsI
02/28
57
0
从头开始搭建一个dubbo+zookeeper平台

本篇主要是来分享从头开始搭建一个dubbo+zookeeper平台的过程,其中会简要介绍下dubbo服务的作用。 首先,看下一般网站架构随着业务的发展,逻辑越来越复杂,数据量越来越大,交互越来越多之...

Java干货分享
2018/10/11
40
0

没有更多内容

加载失败,请刷新页面

加载更多

Linux 运行shell文件,出现 $'\r': command not found

运行编写的shell脚本时,出现了 $'\\r': command not found 这样的错误提示。 报错的原因是我们在windows系统操作时,编辑器里的换行符是\r\n ,而Linux上为\n,两个系统之间有差异导致的。 ...

芥末无敌
今天
10
0
Java数据结构(上)

枚举(Enumeration) 位集合(BitSet) 向量(Vector) 栈(Stack) 1.Enumeration(枚举) boolean hasMoreElements( ):测试是否有更多的元素 Object nextElement( ):如果此枚举对象至少还...

Firefly-
昨天
18
0
vue 跨层组件通讯 provide inject

https://cn.vuejs.org/v2/api/#provide-inject 类型: provide:Object | () => Object inject:Array<string> | { [key: string]: string | Symbol | Object } 详细: provide 和 inject 主......

阿豪boy
昨天
14
0
黑马程序员面试宝典(Java)Beta6.0免费下载

场景 JavaSE基础 面向对象特征以及理解 访问权限修饰符区别 理解clone对象 JavaSE语法 java有没有goto语句 &和&&的区别 如何跳出当前的多重嵌套循环? 是否可以继承String? 重载与重写的区别...

badaoliumang
昨天
14
0
监控linux系统状态

查看系统负载: w/uptime 最后面三个数字表示1分钟,5分钟,15分钟平均有多少个进程占用CPU 占用CPU的进程可以是Running,也可以是Waiting 某一时刻1颗CPU只能有一个进程在使用其资源 #查看c...

asnfuy
昨天
14
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部