文档章节

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

卖女孩的小火柴
 卖女孩的小火柴
发布于 2017/02/09 09:34
字数 1037
阅读 122
收藏 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
厦门
其他
[置顶] Java集群优化——dubbo+zookeeper构建高可用分布式集群

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

梵蒂冈考虑过
2016/08/09
84
1
Dubbo与Zookeeper、SpringMVC整合和使用

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

wangrikui
2016/03/30
752
0
从头开始搭建一个dubbo+zookeeper平台

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

如何让他和
2016/08/11
88
1
从头开始搭建一个dubbo+zookeeper平台

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

如何让他和
2016/08/07
15
0
从头开始搭建一个dubbo+zookeeper平台

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

梵蒂冈考虑过
2016/08/13
76
1

没有更多内容

加载失败,请刷新页面

加载更多

window.parent,top,window.self,parent,opener

在应用有frameset或者iframe的页面时,parent是父窗口,top是最顶级父窗口(有的窗口中套了好几层frameset或者iframe),self是当前窗口, opener是用open方法打开当前窗口的那个窗口。 wind...

inidcard
10分钟前
1
0
Linux下Redis的安装和部署

一、Redis介绍 Redis是当前比较热门的NOSQL系统之一 它是一个key-value存储系统。和Memcache类似,但很大程度补偿了Memcache的不足,它支持存储的value类型相对更多,包括string、list、set...

曾大大胖
14分钟前
1
0
开源堡垒机jumpserver搭建

概述 之前说了国产良心kodexplorer,今天再说一个国内比较好的开源项目jumpserver,除此之外还可以的国内开源项目我觉得就是宝塔面板了。废话不多说上教程搭建。 虽然说你可以看下面的教程不...

bboysoulcn
19分钟前
2
0
iPhoneX 底部距离

iPhoneX 底部距离 CGFloat adjust = 0; if (@available(iOS 11.0, *)) { //Account for possible notch UIEdgeInsets safeArea = [[UIApplication sharedApplication] keyWindow].safeAreaIn......

壹峰
23分钟前
2
0
养生篇01 (饭水分离法)

作者简介❤李祥文,1939年出生于韩国庆尚北道尚州市成昌邑。 24岁时,偶遇奇人习得这种分别喝水吃饭的养生方法,从而治好了自己的胃病和哮喘。从此,李祥文对饮食之于人体的影响产生了极大的...

十九亿少女的梦
39分钟前
6
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部