Java Code Examples for io.jboot.app.JbootApplication#setBootArg()

The following examples show how to use io.jboot.app.JbootApplication#setBootArg() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbController.java    From jboot with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {

        //设置 数据源 的相关信息
        JbootApplication.setBootArg("jboot.datasource.type", "mysql");
        JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://127.0.0.1:3306/jbootdemo");
        JbootApplication.setBootArg("jboot.datasource.user", "root");
        JbootApplication.setBootArg("jboot.datasource.password", "123456");
        JbootApplication.setBootArg("jboot.model.unscanPackage", "*");
        JbootApplication.setBootArg("jboot.model.scanPackage", "io.jboot.test.db.model");
        JbootApplication.setBootArg("undertow.devMode", "false");

        //启动应用程序
        JbootApplication.run(args);

        Columns columns = Columns.create();
        columns.between("id",1,5);
        List<User> users = new User().findListByColumns(columns);
        System.out.println(Arrays.toString(users.toArray()));

    }
 
Example 2
Source File: DubboClientZookeeperDemo.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        //jboot端口号配置
        JbootApplication.setBootArg("undertow.port", "9999");

        JbootApplication.setBootArg("jboot.rpc.type", "dubbo");

        // dubbo 的注册中心的协议,支持的类型有 dubbo, multicast, zookeeper, redis, consul(2.7.1), sofa(2.7.2), etcd(2.7.2), nacos(2.7.2)
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.protocol", "zookeeper");
        //注册中心地址,即zookeeper的地址
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.address", "127.0.0.1:2181");

        JbootApplication.run(args);
    }
 
Example 3
Source File: RedisMqReceiver1.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        //Undertow端口号配置
        JbootApplication.setBootArg("undertow.port", "8001");

        //设置 mq 的相关信息
        JbootApplication.setBootArg("jboot.mq.type", "redis");
        JbootApplication.setBootArg("jboot.mq.channel", "channel1,channel2,myChannel");
        JbootApplication.setBootArg("jboot.mq.redis.host", "127.0.0.1");

        //启动应用程序
        JbootApplication.run(args);

        //添加监听
        Jboot.getMq().addMessageListener((channel, message) -> {
            System.out.println("listener1 receive msg : " + message + ", from channel : " + channel);
        });

        // 只监听 myChannel 这个通道
        Jboot.getMq().addMessageListener((channel, message) -> {
            System.out.println("listener2 receive msg : " + message + ", from channel : " + channel);
        },"myChannel");

        Jboot.getMq().startListening();

        System.out.println("RedisMqReceiver1 started.");
    }
 
Example 4
Source File: MotanClientZookeeperDemo.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        //jboot端口号配置
        JbootApplication.setBootArg("undertow.port", "9999");

        JbootApplication.setBootArg("jboot.rpc.type", "motan");

        // motan 的注册中心的协议
        JbootApplication.setBootArg("jboot.rpc.motan.registry.regProtocol", "zookeeper");
        // 注册中心地址,即zookeeper的地址
        JbootApplication.setBootArg("jboot.rpc.motan.registry.address", "127.0.0.1:2181");

        JbootApplication.run(args);
    }
 
Example 5
Source File: RedisMqReceiver2.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        //Undertow端口号配置
        JbootApplication.setBootArg("undertow.port", "8002");

        //设置 mq 的相关信息
        JbootApplication.setBootArg("jboot.mq.type", "redis");
        JbootApplication.setBootArg("jboot.mq.channel", "channel1,channel2,myChannel");
        JbootApplication.setBootArg("jboot.mq.redis.host", "127.0.0.1");

        //启动应用程序
        JbootApplication.run(args);

        //添加监听
        Jboot.getMq().addMessageListener((channel, message) -> {
            System.out.println("listener1 receive msg : " + message + ", from channel : " + channel);
        });

        // 只监听 myChannel 这个通道
        Jboot.getMq().addMessageListener((channel, message) -> {
            System.out.println("listener2 receive msg : " + message + ", from channel : " + channel);
        },"myChannel");

        Jboot.getMq().startListening();

        System.out.println("RedisMqReceiver1 started.");
    }
 
Example 6
Source File: StockApplication.java    From jboot with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {

        //jboot端口号配置
        JbootApplication.setBootArg("undertow.port", "8081");
        JbootApplication.setBootArg("jboot.rpc.type", "dubbo");
        JbootApplication.setBootArg("jboot.rpc.callMode", "registry");//注册中心模式
        JbootApplication.setBootArg("jboot.rpc.registryType", "zookeeper");//注册中心的类型:zookeeper
        JbootApplication.setBootArg("jboot.rpc.registryAddress", "127.0.0.1:2181");//注册中心,即zookeeper的地址

        //开启 @RPCBean 自动暴露功能,默认情况下是自动暴露的,但是 jboot.properties 文件关闭了,这里需要开启下
        JbootApplication.setBootArg("jboot.rpc.autoExportEnable", true);
        JbootApplication.setBootArg("jboot.rpc.filter", "seata");
        JbootApplication.setBootArg("jboot.seata.enable", true);
        JbootApplication.setBootArg("jboot.seata.failureHandler", "com.alibaba.io.seata.tm.api.DefaultFailureHandlerImpl");
        JbootApplication.setBootArg("jboot.seata.applicationId", "Dubbo_Seata_Stock_Service");
        JbootApplication.setBootArg("jboot.seata.txServiceGroup", "dubbo_seata_tx_group");

        JbootApplication.setBootArg("jboot.datasource.type", "mysql");
        JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://192.168.0.100:3306/mini?useSSL=false&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull");
        JbootApplication.setBootArg("jboot.datasource.user", "root");
        JbootApplication.setBootArg("jboot.datasource.password", "123456");
        
        JbootApplication.setBootArg("jboot.model.unscanPackage", "*");
        JbootApplication.setBootArg("jboot.model.scanPackage", "io.jboot.test.seata.commons");

        JbootApplication.run(args);


        System.out.println("StockApplication started...");


    }
 
Example 7
Source File: MetricsInfluxdbController.java    From jboot with Apache License 2.0 5 votes vote down vote up
/**
 * 配置 reporter 为slf4j 输出
 *
 * 当用户访问的时候,log 定时会输出 index() 的访问次数和当前并发量,1分钟输出一次
 * 同时,配置  jboot.metric.url = /metrics_admin
 * 可以通过浏览器访问 /metrics_admin 查看当前的 index() 的并发量和访问次数
 *
 * PS:只有通过浏览器访问 http://127.0.0.1:8888/metrics/influxdb 才会生成 metrics 记录
 *
 * @param args
 */
public static void main(String[] args) {
    JbootApplication.setBootArg("jboot.metric.url", "/metrics_admin");
    JbootApplication.setBootArg("jboot.metric.reporter", "influxdb");

    JbootApplication.setBootArg("jboot.metric.reporter.influxdb.host", "127.0.0.1");
    JbootApplication.setBootArg("jboot.metric.reporter.influxdb.port", 8086);
    JbootApplication.setBootArg("jboot.metric.reporter.influxdb.user", "admin");
    JbootApplication.setBootArg("jboot.metric.reporter.influxdb.password", "123456");
    JbootApplication.setBootArg("jboot.metric.reporter.influxdb.dbName", "metricsDb");

    JbootApplication.run(args);
}
 
Example 8
Source File: DubboClient.java    From jboot with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {


        //Undertow端口号配置
        JbootApplication.setBootArg("undertow.port", "9999");

        //RPC配置
        JbootApplication.setBootArg("jboot.rpc.type", "dubbo");
        JbootApplication.setBootArg("jboot.rpc.autoExportEnable", false);

        //设置直连模式,方便调试,默认为注册中心
        JbootApplication.setBootArg("jboot.rpc.urls", "io.jboot.test.rpc.commons.BlogService:127.0.0.1:28080");


        JbootApplication.run(args);
    }
 
Example 9
Source File: AddonGenerator.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void genCode() {


        JbootApplication.setBootArg("jboot.datasource.url", dbUrl);
        JbootApplication.setBootArg("jboot.datasource.user", dbUser);
        JbootApplication.setBootArg("jboot.datasource.password", dbPassword);

        String baseModelPackage = modelPackage + ".base";

        String modelDir = basePath + "/src/main/java/" + modelPackage.replace(".", "/");
        String baseModelDir = basePath + "/src/main/java/" + baseModelPackage.replace(".", "/");

        System.out.println("start generate... dir:" + modelDir);

        MetaBuilder metaBuilder = CodeGenHelpler.createMetaBuilder();
        metaBuilder.setGenerateRemarks(true);
        List<TableMeta> tableMetas = metaBuilder.build();

        Set<String> genTableNames = StrUtil.splitToSet(dbTables, ",");
        tableMetas.removeIf(tableMeta -> genTableNames != null && !genTableNames.contains(tableMeta.name.toLowerCase()));


        new BaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        new ModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetas);

        String apiPath = basePath + "/src/main/java/" + servicePackage.replace(".", "/");
        String providerPath = basePath + "/src/main/java/" + servicePackage.replace(".", "/") + "/provider";

        new ServiceApiGenerator(servicePackage, modelPackage, apiPath).generate(tableMetas);
        new ServiceProviderGenerator(servicePackage, modelPackage, providerPath).generate(tableMetas);

        if (genUI) {
            new AddonUIGenerator(basePath, addonName, modelPackage, tableMetas)
                    .genControllers()
                    .genEdit()
                    .genList();
        }

        Set<String> optionsTableNames = StrUtil.splitToSet(optionsTables, ",");
        if (optionsTableNames != null && optionsTableNames.size() > 0) {
            tableMetas.removeIf(tableMeta -> !optionsTableNames.contains(tableMeta.name.toLowerCase()));
            new BaseOptionsModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        }
    }
 
Example 10
Source File: DubboServer.java    From jboot with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {


        JbootApplication.setBootArg("jboot.rpc.type", "dubbo");

        // 开启 @RPCBean 自动暴露功能,默认情况下是开启的,无需配置,
        // 但是此测试代码的 jboot.properties 文件关闭了,这里需要开启下
        JbootApplication.setBootArg("jboot.rpc.autoExportEnable", true);

        //dubbo 的通信协议配置
        JbootApplication.setBootArg("jboot.rpc.dubbo.protocol.name", "dubbo");
        JbootApplication.setBootArg("jboot.rpc.dubbo.protocol.port", "28080");


        JbootSimpleApplication.run(args);

        System.out.println("DubboServer started...");

    }
 
Example 11
Source File: ModeGenTester.java    From jboot with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {

        JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://127.0.0.1:3306/jbootdemo");
        JbootApplication.setBootArg("jboot.datasource.user", "root");

        String modelPackage = "io.jboot.codegen.test";
        String baseModelPackage = modelPackage + ".base";

        String modelDir = PathKit.getWebRootPath() + "/src/main/java/" + modelPackage.replace(".", "/");
        String baseModelDir = PathKit.getWebRootPath() + "/src/main/java/" + baseModelPackage.replace(".", "/");

        System.out.println("start generate...");
        System.out.println("generate dir:" + modelDir);

        new JbootBaseModelGenerator(baseModelPackage, baseModelDir).generate();
        new JbootModelGenerator(modelPackage, baseModelPackage, modelDir).generate();

    }
 
Example 12
Source File: ShrioApp.java    From jboot with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {

        JbootApplication.setBootArg("jboot.shiro.loginUrl","/shiro/doLogin");
        JbootApplication.setBootArg("jboot.shiro.ini","shiro.ini");
        JbootApplication.run(args);
    }
 
Example 13
Source File: DubboClientNacosDemo.java    From jboot with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {

        //jboot端口号配置
        JbootApplication.setBootArg("undertow.port", "9004");

        JbootApplication.setBootArg("jboot.rpc.type", "dubbo");


        // dubbo 的注册中心的协议,支持的类型有 dubbo, multicast, zookeeper, redis, consul(2.7.1), sofa(2.7.2), etcd(2.7.2), nacos(2.7.2)
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.protocol", "nacos");
        //注册中心地址,即 nacos 的地址
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.address", "127.0.0.1:8848");



        JbootApplication.run(args);
    }
 
Example 14
Source File: DubboClientMultiDemo.java    From jboot with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {

        //jboot端口号配置
        JbootApplication.setBootArg("undertow.port", "9005");

        JbootApplication.setBootArg("jboot.rpc.type", "dubbo");


        //两个注册中心,id 分别为 default、zk
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.protocol", "nacos");
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.address", "127.0.0.1:8848");

        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.zk.protocol", "zookeeper");
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.zk.address", "127.0.0.1:2181");



        JbootApplication.run(args);
    }
 
Example 15
Source File: SystemGenerator.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) {

        String dbTables = "user,attachment,menu,option,payment_record,permission,role,utm," +
                "wechat_menu,wechat_reply," +
                "member,member_group,member_dist_amount,member_joined_record,member_price," +
                "user_address,user_amount,user_amount_statement,user_amount_payout," +
                "coupon,coupon_code,coupon_used_record," +
                "user_cart,user_order,user_order_item,user_order_delivery,user_order_invoice," +
                "user_openid,user_favorite,user_tag," +
                "payment_record";

        String optionsTables = "coupon,member,member_group,product,product_category,user_address," +
                "user_amount_statement,user_amount_payout,user_cart,user_order,user_order_item,user_order_delivery,user_order_invoice," +
                "payment_record,user_openid,member_joined_record,user_favorite,user_tag";

        JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://127.0.0.1:3306/jpress3");
        JbootApplication.setBootArg("jboot.datasource.user", "root");
        JbootApplication.setBootArg("jboot.datasource.password", "123456");

        String modelPackage = "io.jpress.model";

        String baseModelPackage = modelPackage + ".base";

        String modelDir = PathKit.getWebRootPath() + "/../jpress-model/src/main/java/" + modelPackage.replace(".", "/");
        String baseModelDir = PathKit.getWebRootPath() + "/../jpress-model/src/main/java/" + baseModelPackage.replace(".", "/");

        System.out.println("start generate...dir:" + modelDir);

        Set<String> genTableNames = StrUtil.splitToSet(dbTables, ",");
        MetaBuilder metaBuilder = CodeGenHelpler.createMetaBuilder();
        metaBuilder.setGenerateRemarks(true);
        List<TableMeta> tableMetas = metaBuilder.build();
        tableMetas.removeIf(tableMeta -> genTableNames != null && !genTableNames.contains(tableMeta.name.toLowerCase()));


        new BaseModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        new ModelGenerator(modelPackage, baseModelPackage, modelDir).generate(tableMetas);

        String servicePackage = "io.jpress.service";
        String apiPath = PathKit.getWebRootPath() + "/../jpress-service-api/src/main/java/" + servicePackage.replace(".", "/");
        String providerPath = PathKit.getWebRootPath() + "/../jpress-service-provider/src/main/java/" + servicePackage.replace(".", "/") + "/provider";


        new ServiceApiGenerator(servicePackage, modelPackage, apiPath).generate(tableMetas);
        new ServiceProviderGenerator(servicePackage, modelPackage, providerPath).generate(tableMetas);

        Set<String> optionsTableNames = StrUtil.splitToSet(optionsTables, ",");
        if (optionsTableNames != null && optionsTableNames.size() > 0) {
            tableMetas.removeIf(tableMeta -> !optionsTableNames.contains(tableMeta.name.toLowerCase()));
            new BaseOptionsModelGenerator(baseModelPackage, baseModelDir).generate(tableMetas);
        }
    }
 
Example 16
Source File: ServiceGenTester.java    From jboot with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {

        JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://127.0.0.1:3306/jbootdemo");
        JbootApplication.setBootArg("jboot.datasource.user", "root");

        String basePackage = "io.jboot.codegen.service.test";
        String modelPackage = "io.jboot.codegen.model.test";


        System.out.println("start generate...");

        new JbootServiceInterfaceGenerator(basePackage, modelPackage).generate();
        new JbootServiceImplGenerator(basePackage, modelPackage).generate();


        System.out.println("service generate finished !!!");

    }
 
Example 17
Source File: MetricsController.java    From jboot with Apache License 2.0 3 votes vote down vote up
/**
 * 配置 reporter 为slf4j 输出
 *
 * 当用户访问的时候,log 定时会输出 index() 的访问次数和当前并发量,1分钟输出一次
 * 同时,配置  jboot.metric.url = /metrics_admin
 * 可以通过浏览器访问 /metrics_admin 查看当前的 index() 的并发量和访问次数
 *
 * PS:只有通过浏览器访问 http://127.0.0.1:8888/metrics 才会生成 metrics 记录
 *
 * @param args
 */
public static void main(String[] args) {
    JbootApplication.setBootArg("jboot.metric.url", "/metrics_admin");
    JbootApplication.setBootArg("jboot.metric.reporter", "slf4j");

    JbootApplication.run(args);
}
 
Example 18
Source File: DubboServer2NacosDemo.java    From jboot with Apache License 2.0 3 votes vote down vote up
public static void main(String[] args)  {

        // 开启 @RPCBean 自动暴露功能,默认情况下是开启的,无需配置,
        // 但是此测试代码的 jboot.properties 文件关闭了,这里需要开启下
        JbootApplication.setBootArg("jboot.rpc.autoExportEnable", true);
        JbootApplication.setBootArg("jboot.rpc.type", "dubbo");



        // dubbo 的注册中心的协议,支持的类型有 dubbo, multicast, zookeeper, redis, consul(2.7.1), sofa(2.7.2), etcd(2.7.2), nacos(2.7.2)
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.protocol", "nacos");
        //注册中心地址,即zookeeper的地址
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.address", "127.0.0.1:8848");


        //dubbo 的通信协议配置,name 可以不用配置,默认值为 dubbo
        JbootApplication.setBootArg("jboot.rpc.dubbo.protocol.name", "dubbo");
        //dubbo 的通信协议配置,如果port配置为-1,则会分配一个没有被占用的端口。
        JbootApplication.setBootArg("jboot.rpc.dubbo.protocol.port", "28081");

        JbootSimpleApplication.run(args);



        System.out.println("DubboServer2NacosDemo started...");


    }
 
Example 19
Source File: DubboClientZkDemo.java    From jboot with Apache License 2.0 3 votes vote down vote up
public static void main(String[] args) {

        //jboot端口号配置
        JbootApplication.setBootArg("undertow.port", "9003");

        JbootApplication.setBootArg("jboot.rpc.type", "dubbo");


        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.zk.protocol", "zookeeper");
        JbootApplication.setBootArg("jboot.rpc.dubbo.registry.zk.address", "127.0.0.1:2181");


        JbootApplication.run(args);
    }
 
Example 20
Source File: MotanServer2ZookeeperDemo.java    From jboot with Apache License 2.0 3 votes vote down vote up
public static void main(String[] args)  {


        // 开启 @RPCBean 自动暴露功能,默认情况下是开启的,无需配置,
        // 但是此测试代码的 jboot.properties 文件关闭了,这里需要开启下
        JbootApplication.setBootArg("jboot.rpc.autoExportEnable", true);
        JbootApplication.setBootArg("jboot.rpc.type", "motan");



        // motan 的注册中心的协议
        JbootApplication.setBootArg("jboot.rpc.motan.registry.regProtocol", "zookeeper");
        //注册中心地址,即zookeeper的地址
        JbootApplication.setBootArg("jboot.rpc.motan.registry.address", "127.0.0.1:2181");


        //export
        JbootApplication.setBootArg("jboot.rpc.motan.defaultExport", "default:28081");

        JbootSimpleApplication.run(args);



        System.out.println("MotanServer2ZookeeperDemo started...");


    }