Coder Social home page Coder Social logo

sofastack / sofa-boot Goto Github PK

View Code? Open in Web Editor NEW
4.9K 316.0 1.3K 4.95 MB

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.

Home Page: https://www.sofastack.tech/sofa-boot/docs/Home

License: Apache License 2.0

Shell 0.01% Java 99.99%
sofa-boot sofa-boot-starter sofastack

sofa-boot's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sofa-boot's Issues

替换rest序列化包

最近在使用rest协议时,返回实体属性默认使用了codehaus这个序列化包(在返回实体属性上加上codehaus的注解有效,使用其他的(fastxml,fastjson,sofarpc的都无效),如何才能改变返回序列包?请大神赐教

SOFABoot Integration testing

Question

In SOFABoot, we should provide one integration testing cases.In this integration testing module, SOFABoot can mainly test the starters managed dependency by SOFABoot.

Your advice

Provide one SOFABoot integration testing project for testing all starters, avoid version conflict and dependency runtime error.In this integration testing project, we should always run successfully before release SOFABoot.

change ServiceFactoryBean getObject return value

getObject method and getObjectType method of ServiceFactoryBean:

@Override
public Object getObject() throws Exception {
    return ref;
}

@Override
public Class<?> getObjectType() {
    return ref != null ? ref.getClass() : Service.class;
}

we shouldn't return ref, it will make applicationContext.getBean(ref.getClass()) return more results.

It will lead some odd problems when get null from ReferenceFactoryBean#getObjectType

Currently, it exists some situations where the invocation of com.alipay.sofa.runtime.spring.factory.ReferenceFactoryBean#getObjectType would return null. As ReferenceFactoryBean is a FactoryBean, this situation will make ReferenceFactoryBean to be created in advance and lead some odd problems. So, we should avoid occurrence of null.

SOFABoot HealthCheck disable the actuator exposed endpoints

Background

The Spring Boot Actuator expose some endpoints like this in 1.4.2.RELEASE, but in application exposes these endpoints have secure proplems and may cause secure danger

Solution

In HealthCheck Starter disable the actuator endpoints and only enable these endpoints.

/health
/health/readiness
/sofaboot/versions

But in SOFABoot we provide config to enable the closed actuator endpoints, such as in SOFABoot configure endpoints.heapdump.enabled=true to enable actuator heapdump endpoints.The enabled configuration should be compatible with actuator.

When upgrade Spring Boot to 2.X, the exposed endpoints are onle info,we should consider the compatible.

the method of init() is never used?

hi,
the method of init() in JvmServiceConumer is never used or the method can not find the reference,
but when i install the sofaboot-sample-with-isle can print the result of init() ,
why?

sofarpc restful增加项目前缀的问题

使用rest风格开发项目默认前缀是“/”,修改context-path只对springboot有效,查了些资料使用applicationPath注解或使用resteasy.servlet.mapping.prefix(在本机试了没生效),怎样在sofaboot的rest风格路径中加前缀?

Schema location change to subdomain.

Now the schema location is like this http://sofastack.io/schema/sofaboot. But sofastack.io is an apex domain. sofastack.io is managed by Alipay DNS server, which not supports setting an apex domain.

Maybe we can change the location to a www subdomain, like http://www.sofastack.io/schema/sofaboot.

I noticed that Spring did it like this too:

  • http://www.springframework.org/schema/beans

似乎 SofaRuntimeProperties 中的配置无法生效

在我的项目中,通过 application.yml 设置 SofaRuntimeProperties 的配置无法生效,例如:

com.alipay.sofa.boot.disableJvmFirst=true

看了一下实现,这个配置最早会被 ServiceAnnotationBeanPostProcessor 作为其依赖进行加载,而 @ConfigurationProperties 是通过 ConfigurationPropertiesBindingPostProcessor 进行注入配置的。

在 Spring 上下文中所有 BeanPostProcessor 会在最开始进行加载,并且连带着加载其依赖的 Bean,而又因为 BeanPostProcessor 本身就需要对 Bean 进行处理,所以后加载的 BeanPostProcessor 是无法对之前加载的 BeanPostProcessor 以及其依赖 Bean 进行处理的。

确认步骤:

  1. SofaRuntimeAutoConfiguration 中的 sofaRuntimeProperties 打断点确认其加载时机(且可以通过调用栈找到其依赖方 serviceAnnotationBeanPostProcessor
  2. AbstractAutowireCapableBeanFactory 中的 applyBeanPostProcessorsBeforeInitialization 进行条件断点,确认 sofaRuntimeProperties 被 PostProcessor 处理时 ConfigurationPropertiesBindingPostProcessor 是否存在,理论其不存在则不会注入配置

如果是我会尝试去掉在 BeanPostProcessor 中使用 @ConfigurationProperties 不知道你们有什么更好的建议,我会尝试修复这个问题以及补充一些测试。

使用SofaService注解发布非JVM服务异常(Can not found binding converter for binding type bolt)

  • 正常场景

`@SofaService(bindings = @SofaServiceBinding(bindingType = "jvm"))
@service
public class SampleServiceImpl implements SampleService {

@Override
public String message() {
    return "hello sofa";
}

}
`

  • 异常场景
    `@SofaService(bindings = @SofaServiceBinding(bindingType = "bolt"))
    @service
    public class SampleServiceImpl implements SampleService {

    @OverRide
    public String message() {
    return "hello sofa";
    }
    }
    `

  • 源码部分

if (JvmBinding.JVM_BINDING_TYPE.getType().equals( sofaReferenceAnnotation.binding().bindingType())) { reference.addBinding(new JvmBinding()); } else { BindingConverter bindingConverter = bindingConverterFactory .getBindingConverter(new BindingType(sofaReferenceAnnotation.binding() .bindingType())); if (bindingConverter == null) { throw new ServiceRuntimeException( "Can not found binding converter for binding type " + sofaReferenceAnnotation.binding().bindingType()); }

debug源码部分这个绑定转换器工厂好像没有向这个map里添加绑定转换器!
版本:sofa-boot 2.4.0
SofaRuntimeSpringContextInitializer.initialize这个方法并没有初始化bingdingConverterFactory,所以map里是空的。
看了版本:sofa-boot 2.3.1有初始的操作但是ServiceLoader.load(BindingConverter.class)没有找到关于bolt或者其它类的配置项,相当于bindingConverterFactory里的map转换器还是空的!
麻烦sofa团队大神门帮忙看一下,谢谢啦

MAC OSX下MAVEN生成javadoc报错

报错说明

在OSX系统下IDEA中执行 sofa-boot-runtime 项目的 mvn install 命令,报如下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (attach-javadocs) on project infra-sofa-boot-starter: MavenReportException: Error while creating archive: Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]

问题研究

去网上查询解决方法,发现大多和 maven-javadoc-plugin 2.9.x 版本相关,以下是stack overflow上的相关讨论:

JAVA_HOME on OSX with Eclipse and Maven

自己尝试了以下两种方式,都不再报错:

  1. 在 pom.xml 文件的 properties 属性中添加以下配置:
    <javadocExecutable>${java.home}/../bin/javadoc</javadocExecutable>
  2. 升级 maven-javadoc-plugin 版本到 2.10.1 及以上。

猜测可能是该插件 2.9.x 版本存在的bug,尝试去查询该插件之后的提交说明,但是没有找到明确相关的说明,在这反馈一下这个问题。

执行环境:

  • Java版本:1.8.0_171
  • 系统版本:macOS High Sierra 10.13.6
  • Maven版本:3.5.4
  • IDE 版本:IDEA 2018.1.2

Provide Gradle dependency management plugin

Spring Boot has a Gradle dependency management plugin to manage the dependencies, maybe SOFABoot should also provide one.

Following is the example of a Spring Boot Gradle build script:

buildscript {
	ext {
		springBootVersion = '2.0.3.RELEASE'
	}
	repositories {
		mavenCentral()
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
	}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
	mavenCentral()
}


dependencies {
	compile('org.springframework.boot:spring-boot-starter')
	testCompile('org.springframework.boot:spring-boot-starter-test')
}

English syntax is poor in the introduction

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provide readiness check, class isolation, etc.

"compatible" is a adj not verb and "provide" should be "provides"

导入sofa-rpc-boot-projects项目源码到sts出错

本机安装jdk1.8,开发工具sts,将sofa-rpc-boot-projects导入sts出错,部分jar包找不到,
出错原因
Description Resource Path Location Type
Missing artifact com.alipay.sofa:healthcheck-sofa-boot-starter:jar:2.4.0 pom.xml /sofa-boot-samples line 31 Maven Dependency Problem
Missing artifact com.alipay.sofa:rpc-sofa-boot-starter:jar:5.4.0 pom.xml /sofa-boot-samples line 21 Maven Dependency Problem
Missing artifact com.alipay.sofa:test-sofa-boot-starter:jar:2.4.0 pom.xml /sofa-boot-samples line 26 Maven Dependency Problem
Plugin execution not covered by lifecycle configuration: com.googlecode.maven-java-formatter-plugin:maven-java-formatter-plugin:0.4:format (execution: default, phase: process-sources) pom.xml /sofa-boot-samples line 7 Maven Project Build Lifecycle Mapping Problem
Plugin execution not covered by lifecycle configuration: org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:prepare-agent (execution: pre-test, phase: process-classes) pom.xml /sse-boot-web-endpoint line 5 Maven Project Build Lifecycle Mapping Problem
Plugin execution not covered by lifecycle configuration: org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:prepare-agent (execution: pre-test, phase: process-classes) pom.xml /sse-boot-web-web line 6 Maven Project Build Lifecycle Mapping Problem
Project build error: Non-resolvable parent POM for com.alipay.sofa:rpc-sofa-boot-starter:5.4.0: Failure to find com.alipay.sofa:sofaboot-dependencies:pom:2.4.0 in http://mvn.cloud.alipay.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of mirror-all has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM pom.xml /sofa-boot-starter line 5 Maven pom Loading Problem
The container 'Maven Dependencies' references non existing library 'D:\javax\repo\com\alipay\sofa\rpc-sofa-boot-starter\5.4.0\rpc-sofa-boot-starter-5.4.0.jar' sofa-boot-samples Build path Build Path Problem
The project cannot be built until build path errors are resolved sofa-boot-samples Unknown Java Problem

Provide a SOFABoot banner

maybe we need to provide a banner to increase brand identity

${AnsiColor.BRIGHT_GREEN}
 ,---.    ,-----.  ,------.   ,---.     ,-----.                     ,--.
'   .-'  '  .-.  ' |  .---'  /  O  \    |  |) /_   ,---.   ,---.  ,-'  '-.
`.  `-.  |  | |  | |  `--,  |  .-.  |   |  .-.  \ | .-. | | .-. | '-.  .-'
.-'    | '  '-'  ' |  |`    |  | |  |   |  '--' / ' '-' ' ' '-' '   |  |
`-----'   `-----'  `--'     `--' `--'   `------'   `---'   `---'    `--'

Ant Financial Services Group
${AnsiColor.BRIGHT_RED}
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}

this wil show a banner like

image

sofaboot-sample-with-isolation跑不通

编译主项目之后, sample-with-isolation跑不通,
找不到sofa-ark-maven-plugin 这个插件, 另外还看到有sofa-ark-plugin-maven-plugin. 请问这两个插件哪里去下载?

另外还有rpc-sofa-boot-starter 也是下载不到.

SOFABoot 代码阅读发现的一些问题

  • SofaBootLogSpaceIsolationInit 原打算应该是做初始化日志的公用类,但是现在runtime、infra、healthcheck都是各自初始化,一些代码也是重复执行
  • 注释有些地方是直接copy的,和代码不契合,如 InfraHealthCheckLoggerFactory类第48行注释。 另外 Javadoc 标签有些地方没用好
  • SofaBootVersionEndpoint 普通的 endpoint 和 mvcendpoint 共存,在设置disable/enable时会存在bug, 需要使用 @ConfigurationProperties 配置相同的 prefix
  • 建议所有的版本信息都继承 AbstractSofaBootMiddlewareVersionFacade 接口,而不需要分成两种不同的形式处理,另外该 RuntimeInfo 方法返回空map,不要返回null。
  • HealthCheckConfigurationConstants 中删除不用的变量,有些变量其他地方有定义。另外这类一部分功能用于获取环境变量,不够 SpringBoot 风格,可以尝试换成 @ConfigurationProperties 注解
  • SofaBootReadinessCheckEndpoint 同样有 SofaBootVersionEndpoint 一样的问题
  • DefaultHealthChecker 是一个抽象类,按照其作用,命名 AbstractHealthCheckerAdapater 可能更好,或者不要定义成抽象类
  • 代码很多无端的空行分隔,比如 com.alipay.sofa.healthcheck.startup.ReadinessCheckProcessor#startHealthCheckProcess
  • com.alipay.sofa.healthcheck.core.ComponentCheckProcessor#httpCheckComponent 日志打印错误,另外建议名字改成liveness check
  • HealthCheckManager 有不少从 ApplicationContext 拿特定类型的类,可以封装一下成getBeansOfType(Class, Filter)
  • 有 SofaBootBeforeReadinessCheckEvent ,但是没有对应的 After 事件,而是换成了 Callback 接口,这一块能不能同意下?
  • Component 类 85 行注释错误
  • referenceImpl 和 serviceImpl 改下 toString 需要改下,需要拼装上 uniqid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.