From 8396c2862965632bdaaa677061b750b56224caa3 Mon Sep 17 00:00:00 2001 From: tobato Date: Thu, 15 Jun 2017 00:04:10 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFfix(config):=20fix=20jmx=20already=20r?= =?UTF-8?q?egistered=20with=20name=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix jmx already registered with name. add doc to project Closes #18,#8 --- .gitignore | 3 +- CHANGELOG.md | 20 +++++++ pom.xml | 5 ++ readme.md | 12 ++-- src/doc/01_Release.md | 55 +++++++++++++++++++ .../fastdfs/conn/ConnectionPoolConfig.java | 9 +++ .../fastdfs/FastdfsTestApplication.java | 3 + src/test/resources/application.yml | 7 --- 8 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 src/doc/01_Release.md diff --git a/.gitignore b/.gitignore index 7fa9097..66d354b 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ pom.xml.versionsBackup pom.xml.next release.properties dependency-reduced-pom.xml -buildNumber.properties \ No newline at end of file +buildNumber.properties +/.apt_generated/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 037408b..815b881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +## 1.25.4 (2017-06-14) + +Bugfixes: + + - 解决在SpringBoot项目当中JMX重复注册的问题 (#8,#18,@flykarry,@SevenSecondsOfMemory) + + 错误信息 + + javax.management.InstanceAlreadyExistsException: MXBean already registered with name org.apache.commons.pool2:type=GenericKeyedObjectPool,name=pool + + 解决办法配置 + + @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) + + + +Docs: + + - 增加文档目录,把相关文档完善提交一下 + ## 1.25.3 (2017-03-11) Features: diff --git a/pom.xml b/pom.xml index cc729da..6797f1e 100644 --- a/pom.xml +++ b/pom.xml @@ -266,6 +266,11 @@ thumbnailator 0.4.8 + + org.springframework.boot + spring-boot-configuration-processor + true + diff --git a/readme.md b/readme.md index d24fce9..b58d21e 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -FastDFS-Client 1.25.3-RELEASE(2017-03-11) +FastDFS-Client 1.25.4-RELEASE(2017-06-14) --- This is a java client lib for [FastDFS](https://github.com/happyfish100/fastdfs). @@ -62,13 +62,13 @@ Maven依赖为 com.github.tobato fastdfs-client - 1.25.3-RELEASE + 1.25.4-RELEASE ### 2.将Fdfs配置引入项目 -将FastDFS-Client客户端引入本地化项目的方式非常简单,在SpringBoot项目当中 +将FastDFS-Client客户端引入本地化项目的方式非常简单,在SpringBoot项目`/src/[com.xxx.主目录]/conf`当中配置 /** * 导入FastDFS-Client组件 @@ -78,11 +78,15 @@ Maven依赖为 */ @Configuration @Import(FdfsClientConfig.class) + // 解决jmx重复注册bean的问题 + @EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) public class ComponetImport { // 导入依赖组件 } -是的,只需要一行注解 @Import(FdfsClientConfig.class) +对的,只需要一行注解 @Import(FdfsClientConfig.class)就可以拥有带有连接池的FastDFS Java客户端了。 + +>注意:`@EnableMBeanExport`解决问题JMX重复注册问题,[issue #8](./issues/8) [issue #18](./issues/8),不要再配置 `spring.jmx.enabled=false`,以免影响SpringBoot默认的JMX监控。 ### 3.在application.yml当中配置Fdfs相关参数 # =================================================================== diff --git a/src/doc/01_Release.md b/src/doc/01_Release.md new file mode 100644 index 0000000..8eb5ec9 --- /dev/null +++ b/src/doc/01_Release.md @@ -0,0 +1,55 @@ +项目发布 +---- + + 记录项目发布的过程,免得每次发布都重新想一遍。 + +## Docker环境准备 + + 启动Docker以后需要把FDFS服务打开 + + bash + /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf + /usr/bin/fdfs_storaged /etc/fdfs/storage.conf + +## 发布流程 + +### 1.修改文档 + +发布前先调整Readme.md 和 Changelog.md + +### 2.项目发布准备 + + mvn release:prepare -P release + +>回滚失败的发布 +> +> mvn release:rollback + +### 3.正式发布提交 + + mvn release:peform -P release + +## 参考资料 + +Maven Release Plugin that is used to automate release management. Releasing a project is done in two steps: prepare and perform. + +* Preparing a release goes through the following release phases: + + * Check that there are no uncommitted changes in the sources + * Check that there are no SNAPSHOT dependencies + * Change the version in the POMs from x-SNAPSHOT to a new version (you will be prompted for the versions to use) + * Transform the SCM information in the POM to include the final destination of the tag + * Run the project tests against the modified POMs to confirm everything is in working order + * Commit the modified POMs + * Tag the code in the SCM with a version name (this will be prompted for) + * Bump the version in the POMs to a new value y-SNAPSHOT (these values will also be prompted for) + * Commit the modified POMs + +* Performing a release runs the following release phases: + + * Checkout from an SCM URL with optional tag + * Run the predefined Maven goals to release the project (by default, deploy site-deploy) + + + + diff --git a/src/main/java/com/github/tobato/fastdfs/conn/ConnectionPoolConfig.java b/src/main/java/com/github/tobato/fastdfs/conn/ConnectionPoolConfig.java index 8ea5164..d17beb9 100644 --- a/src/main/java/com/github/tobato/fastdfs/conn/ConnectionPoolConfig.java +++ b/src/main/java/com/github/tobato/fastdfs/conn/ConnectionPoolConfig.java @@ -48,6 +48,12 @@ public class ConnectionPoolConfig extends GenericKeyedObjectPoolConfig { */ public static final int FDFS_NUM_TESTS_PEREVICTION_RUN = -1; + /** 默认jmx域名 */ + public static final String FDFS_JMX_NAME_BASE = "com.github.tobato.fastdfs.conn:type=FdfsConnectionPool"; + + /** 默认jmx prefix名称 */ + public static final String FDFS_JMX_NAME_PREFIX = "fdfsPool"; + public ConnectionPoolConfig() { // 从池中借出的对象的最大数目 setMaxTotal(FDFS_MAX_TOTAL); @@ -63,6 +69,9 @@ public ConnectionPoolConfig() { setTimeBetweenEvictionRunsMillis(FDFS_TIME_BETWEEN_EVICTION_RUNS_MILLIS); // 清理时候检查所有线程 setNumTestsPerEvictionRun(FDFS_NUM_TESTS_PEREVICTION_RUN); + // 配置jmx + this.setJmxNameBase(FDFS_JMX_NAME_BASE); + this.setJmxNamePrefix(FDFS_JMX_NAME_PREFIX); } } \ No newline at end of file diff --git a/src/test/java/com/github/tobato/fastdfs/FastdfsTestApplication.java b/src/test/java/com/github/tobato/fastdfs/FastdfsTestApplication.java index 6328c54..6a90059 100644 --- a/src/test/java/com/github/tobato/fastdfs/FastdfsTestApplication.java +++ b/src/test/java/com/github/tobato/fastdfs/FastdfsTestApplication.java @@ -2,6 +2,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.EnableMBeanExport; +import org.springframework.jmx.support.RegistrationPolicy; /** * 测试驱动类 @@ -10,6 +12,7 @@ * */ @SpringBootApplication +@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) public class FastdfsTestApplication { public static void main(String[] args) { SpringApplication.run(FastdfsTestApplication.class, args); diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml index deb7f58..f2561f4 100644 --- a/src/test/resources/application.yml +++ b/src/test/resources/application.yml @@ -13,8 +13,6 @@ fdfs: # - 192.168.174.42:22122 # - 192.168.174.48:22122 -spring.jmx.enabled: false - --- spring: profiles: customized_pool @@ -31,8 +29,3 @@ fdfs: maxTotal: 153 #获取连接时的最大等待毫秒数100 maxWaitMillis: 102 - - -spring.jmx.enabled: false - -