编程知识 cdmana.com

Lightweight Java foundation development framework, released by Solon & Solon cloud 1.5.40

Solon existing 120 An ecological extension , This version focuses on detail polishing :

  • increase mybatisplus-solon-plugin plug-in unit
    // thus ,Solon  Has completed the mainstream at home and abroad 5 individual ORM Frame plug-in adaptation 
    
  • plug-in unit solon.validation, annotation Whitelist、NotBlacklist、Logined Add inheritable support
    //
    //Solon  Specific lightweight and complete verification capability and verification extension mechanism 
    //
    @Logined
    @Valid
    public class ApiBaseLogined {
    }
    
    
    @Controller
    public class DemoController extends ApiBaseLogined {
        @Numeric({"id"})
        @NotEmpty({"id","name","description"})
        @Mapping("addArchive")
        public void addArchive(Long id, String name, String description){
            //...
        }
        
        @Mapping("addArchiveItem")
        public void addArchiveItem(@Validated ItemModel item){
            //...
        }
    }
    
  • adjustment Routing rules , belt * The printing and mapping relationship of No. comes back
    @Controller
    public class DemoController {
        @Mapping("/*")
        public void all(){
        }
        
        @Mapping("/add") // be relative to *, Have priority matching 
        public void add(){ 
        }
    }
    
  • adjustment When the communication port is occupied , Throw an exception instead
  • internationalization increase Content-Language Header information support , Make international control more friendly
  • internationalization increase Contextual Locale Injection support
    @Mapping("/demo")
    public void demo(Locale locale){
    
    } 
    
  • internationalization increase I18nService class
    @Controller
    public class DemoController {
        I18nService i18nService = new I18nService("i18n.user");
    
        @Mapping("/demo")
        public String demo(Locale locale){
            return i18nService.get(locale, "user.name");
        }
    }
    
  • adjustment solon.data.cache.CacheServiceDefault Inner class , Renamed LocalCacheService
    @Configuration
    public class Config {
        @Bean
        public CacheService cache(){
            return new LocalCacheService();
        }
    }
    
  • plug-in unit solon.serialization.hession Renamed : plug-in unit solon.serialization.hessian
  • Adjust the serialization rendering scheme , No longer affected accept header influence
  • adjustment Validator Numeric , Empty means pass ( Whether it is allowed to be empty is determined by @NotEmpty Handle )
  • adjustment Aop.get(type) Change it to return bean || null
  • Cancel Aop.getOrNull(type) Interface , from Aop.get(type)
  • newly added Aop.getOrNew(type) return bean; Instead of the old Aop.get(type)
  • Interface CloudFileService increase delete Method
    @Controller
    public class DemoController {
        @Bean
        public void put(UploadedFile file){
            // Alibaba cloud  oss   or  AWS s3  or   Seven cattle   Image upload ( Use  Solon Cloud  The interface will be simple )
            CloudClient.file().putStream(Utils.guid(), file.content, "image/jpg");
        }
    }
    
  • Repair solon.extend.staticfiles There will be .htm Of mine matching .xhtm The situation of
  • Optimization does not enable cache control ( Based on code control , It can be changed according to the startup parameters )
  • Optimize controls that do not enable transactions
  • Adjust the cache tag parameter usage policy , Lack of time is very convenient for users to find
  • increase @Inject("${xx.xx.ary}") List ary Support for
    @Controller
    public class DemoController {
        @Inject("${project.linkes}")
        List<String> linkes;
        
        @Inject("${project.details}")
        Map<String,String> details;
    }
    
  • Repair Props stay forEach when , Duplication may occur key The problem of

About Solon

Solon It's a light weight Java Basic development framework . emphasize , restraint + concise + The principle of openness ; Strive for , smaller 、 faster 、 A freer experience . Support :RPC、REST API、MVC、Job、Micro service、WebSocket、Socket And other development models . Short and sharp !

Solon Cloud Is a series of interface standards and configuration specifications , Count as Solon Distributed development suite based on .

Quickly understand Solon The material of :

《Solon Feature set , Compare with Springboot What's the difference? ?》

《Solon Cloud List of distributed service development kits , Feeling and receiving Spring Cloud Different 》

《Solon Ideas and architecture notes 》

Smaller :

kernel 0.1m, The smallest interface development unit 0.2m( Compare with Dubbo、Springboot The dependency package of , Small enough to be ignored )

Faster :

This machine http helloworld test ,Qps Can be up to 12 Wan Zhi Du . May refer to :《helloworld_wrk_test

More freedom :( Code controls freedom )

//  In addition to annotation mode , You can also do it manually on demand 
//
// Get configuration manually (Props  by  Properties  Enhanced version )
Props db = Solon.cfg().getProp("db");

// Get the... In the container manually Bean
UserService userService = Aop.get(UserService.class);

// Manual monitoring http post request 
Solon.global().post("/user/update", x-> userService.updateById(x.paramMap()));

// Manually add RPC service 
Solon.global().add("/rpc/", HelloService.class, true);

// Get one manually RPC Service consumer 
HelloService helloService = Nami.builder().create(HelloService.class);

// Manually add components to the container 
Aop.wrapAndPut(DemoService.class);

Hello world:

//Handler  Pattern :
public class App{
    public static void main(String[] args){
        SolonApp app = Solon.start(App.class,args);
        
        app.get("/",(c)->c.output("Hello world!"));
    }
}

//Controller  Pattern :(mvc or rest-api)
@Controller
public class App{
    public static void main(String[] args){
        Solon.start(App.class,args);
    }
  
    // limit  put  Method type 
    @Put
    @Mapping("/")
    public String hello(String name){
        return "Hello " + name;
    }
}

//Remoting  Pattern :(rpc)
@Mapping("/")
@Remoting
public class App implements HelloService{
    public static void main(String[] args){
        Solon.start(App.class,args);
    }

    @Override
    public String hello(){
        return "Hello world!";
    }
}

attach : Project address

attach : Introductory example

版权声明
本文为[Liu zhixidong]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/10/20211002145410351m.html

Scroll to Top