boot

Start Service at boot without activity

元气小坏坏 提交于 2019-12-05 13:16:17
I want create an application which contains only a service (no activity). This service must start on boot. My problem is that it seems the boot receiver don't seems call if there aren't activity. I have test with the following example. I have the different files : MyReceiver.java : package com.test.teststartserviceatboot; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; import android.widget.Toast; public class MyReceiver extends BroadcastReceiver { @Override public void onReceive( Context ctx, Intent i ) { Log.v(

SpringBoot的jar包启动

谁说胖子不能爱 提交于 2019-12-05 12:41:14
1.jar包中包含BOOT-INF、META-INF、spring boot loader 2.BOOT-INF包含项目编译的业务代码class 3.META-INF包含pom和启动配置相关信息 4.loader中包含整个jar包的启动入口类 5.通过loader中的Launcher接口进入MainMethodRunner 6.通过MainMethodRunner中的方法反射执行main方法启动整个服务 来源: https://www.cnblogs.com/scaling/p/11925453.html

Spring - Spring 常用注解

╄→гoц情女王★ 提交于 2019-12-05 12:33:19
概述 简单整理一些 Spring 的注解 这个算是一个 水一波 类型的整理 内容不全 分类可能有的地方不会太符合逻辑 而且时间也不太充裕 先把自己想写的写下来, 然后随缘整理吧 约定 版本 Spring 5 后悔 相关的书, 看了 半个月后 才想起来整理 现在看起来, 有点累 有些东西, 可能记的不那么精准 发现问题, 及时修补吧 1. 基本 @SpringBootApplication 概述 spring 入口类的注解 由 3 个老注解合成 类型 类注解 SpringBoot 的入口类 组成 @SpringBootConfiguration 配置类 是 @Configuration 的一个特殊形式 告诉大家, 这是一个 配置类 @EnableAutoConfiguration 选项 开启自动配置 自动配置, 是 spring boot 的特性 用很多的约定代替了配置 @ComponentScan 选项 开启组件扫描 为后面的自动注入, 做了基础 相关注解 @Component @Controller @Service ref Annotation Type SpringBootApplication @Component 概述 spring 组件注解 有子类 @Controller @Service 类型 类注解 组件类 自动扫描 配合 需要与

SpringBoot自定义FailureAnalyzer

北城余情 提交于 2019-12-05 12:31:16
官网说明 1.1 创建自己的 FailureAnalyzer FailureAnalyzer是一种在启动时拦截 exception 并将其转换为 human-readable 消息的好方法,包含在故障分析中。 Spring Boot 为 application context 相关的 exceptions,JSR-303 验证等提供了这样的分析器。实际上很容易创建自己的。 AbstractFailureAnalyzer 是 FailureAnalyzer 的方便扩展,它检查 exception 中是否存在指定的 exception 类型来处理。你可以从中扩展,这样你的 implementation 只有在它实际存在时才有机会处理 exception。如果由于某种原因你无法处理 exception,return null 给另一个 implementation 一个处理 exception 的机会。 FailureAnalyzer __mplement 将在 META-INF/spring.factories 中注册:以下寄存器 ProjectConstraintViolationFailureAnalyzer : org.springframework.boot.diagnostics.FailureAnalyzer=\ com.example

springboot入门

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 12:03:12
Springboot入门 SpringBoot是什么? Spring Boot它本身并不提供Spring框架的核心特性以及扩展功能,只是用于快速、敏捷地开发新一代基于Spring框架的应用程序。也就是说,它并不是用来替代Spring的解决方案,而是和Spring框架紧密结合用于 提升 Spring开发者体验 的工具。 同时它集成了大量常用的第三方库配置(例如Jackson, JDBC, Mongo, Redis, Mail等等),Spring Boot应用中这些第三方库几乎可以 零配置 的开箱即用( out-of-the-box),大部分的Spring Boot应用都只需要非常 少量 的配置代码,开发者能够更加专注于业务逻辑 注1:敏捷式开发 注2:spring boot其实不是什么新的框架,它默认配置了很多框架的使用方式, 就像maven整合了所有的jar包,spring boot整合了所有的框架 使用 Idea配置SpringBoot项目 java源文件夹中的SpringbootApplication.java是整个项目的启动类 static:存放的是静态资源的文件 templetes:存放的项目所需的页面 application.yml里面存放的是项目的全局配置信息     项目启动成功访问界面如下: 来源: https://www.cnblogs.com/bf6rc9qu

HSSF和XSSF

扶醉桌前 提交于 2019-12-05 11:42:15
HSSF是POI工程对Excel(.xls)文件操作的实现,XSSF是POI工程对Excel(.xlsx)文件操作的实现. gradle.build dependencies { compile('org.springframework.boot:spring-boot-starter') testCompile('org.springframework.boot:spring-boot-starter-test') compile('org.apache.poi:poi:3.9') compile('org.apache.poi:poi-ooxml:3.9') compile('org.springframework.boot:spring-boot-starter-web') }``` spring-poi-demo: https://github.com/maomaolsm/spring-poi 来源: oschina 链接: https://my.oschina.net/u/2558286/blog/725116

Spring Boot Admin 服务端

醉酒当歌 提交于 2019-12-05 10:02:22
创建 Spring Boot Admin Server 创建一个工程名为 hello-spring-cloud-admin 的项目, pom.xml 文件如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.snake</groupId> <artifactId>hello-spring-cloud-dependencies</artifactId> <version>1.0.0-SNAPSHOT</version> <relativePath>../hello-spring-cloud-dependencies/pom.xml</relativePath> </parent> <artifactId>hello-spring

Spring Boot Admin 客户端

独自空忆成欢 提交于 2019-12-05 10:02:17
创建 Spring Boot Admin Client 创建一个工程名为 hello-spring-cloud-admin-client 的项目, pom.xml 文件如下: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.snake</groupId> <artifactId>hello-spring-cloud-dependencies</artifactId> <version>1.0.0-SNAPSHOT</version> <relativePath>../hello-spring-cloud-dependencies/pom.xml</relativePath> </parent> <artifactId>hello

Spring Boot Admin

ε祈祈猫儿з 提交于 2019-12-05 10:01:14
随着开发周期的推移,项目会不断变大,切分出的服务也会越来越多,这时一个个的微服务构成了错综复杂的系统。对于各个微服务系统的健康状态、会话数量、并发数、服务资源、延迟等度量信息的收集就成为了一个挑战。Spring Boot Admin 应运而生,它正式基于这些需求开发出的一套功能强大的监控管理系统。 Spring Boot Admin 有两个角色组成,一个是 Spring Boot Admin Server,一个是 Spring Boot Admin Client,本章节将带领大家实现 Spring Boot Admin 的搭建。 来源: https://www.cnblogs.com/snake107/p/11920747.html