首页 » java

spring boot 2 的跨域和1不太一样,具体配置如下
@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {

        registry.addMapping("/**")
                .allowedOrigins(
                        "*")
                .allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD")
                .allowedHeaders("*")
                .allowCredentials(true);
    }
}

测试跨域,可以用这个链接http://test-cors.org/

OOm错误

1.配置gradle.properties

org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError

2.完整报错:

ERROR: Exception while analyzing expression at (54,16) in /home/shenfeng/dev1/thor-android/ModuleUser/src/main/kotlin/com/rr/biz/user/ui/me/adapter/MineAdapter.kt
org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments: Exception while analyzing expression at (54,16) in /home/shenfeng/dev1/thor-android/ModuleUser/src/main/kotlin/com/rr/biz/user/ui/me/adapter/MineAdapter.kt
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.logOrThrowException(ExpressionTypingVisitorDispatcher.java:233)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.lambda$getTypeInfo$0(ExpressionTypingVisitorDispatcher.java:211)
    at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:90)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:161)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:132)
    at org.jetbrains.kotlin.types.expressions.ControlStructureTypingVisitor.visitReturnExpression(ControlStructureTypingVisitor.java:676)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.visitReturnExpression(ExpressionTypingVisitorDispatcher.java:266)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher$ForBlock.visitReturnExpression(ExpressionTypingVisitorDispatcher.java:57)
    at org.jetbrains.kotlin.psi.KtReturnExpression.accept(KtReturnExpression.java:33)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.lambda$getTypeInfo$0(ExpressionTypingVisitorDispatcher.java:172)
    at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:90)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:161)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:132)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorForStatements.visitExpression(ExpressionTypingVisitorForStatements.java:373)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorForStatements.visitExpression(ExpressionTypingVisitorForStatements.java:62)
    at org.jetbrains.kotlin.psi.KtVisitor.visitExpressionWithLabel(KtVisitor.java:226)
    at org.jetbrains.kotlin.psi.KtVisitor.visitReturnExpression(KtVisitor.java:222)
    at org.jetbrains.kotlin.psi.KtReturnExpression.accept(KtReturnExpression.java:33)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.lambda$getTypeInfo$0(ExpressionTypingVisitorDispatcher.java:172)
    at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:90)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:161)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:145)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.getTypeOfLastExpressionInBlock(ExpressionTypingServices.java:345)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.getBlockReturnedTypeWithWritableScope(ExpressionTypingServices.java:284)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.getBlockReturnedType(ExpressionTypingServices.java:202)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.getBlockReturnedType(ExpressionTypingServices.java:179)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorForStatements.visitBlockExpression(ExpressionTypingVisitorForStatements.java:416)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorForStatements.visitBlockExpression(ExpressionTypingVisitorForStatements.java:62)
    at org.jetbrains.kotlin.psi.KtBlockExpression.accept(KtBlockExpression.java:44)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.lambda$getTypeInfo$0(ExpressionTypingVisitorDispatcher.java:172)
    at org.jetbrains.kotlin.util.PerformanceCounter.time(PerformanceCounter.kt:90)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:161)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher.getTypeInfo(ExpressionTypingVisitorDispatcher.java:145)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.checkFunctionReturnType(ExpressionTypingServices.java:174)
    at org.jetbrains.kotlin.types.expressions.ExpressionTypingServices.checkFunctionReturnType(ExpressionTypingServices.java:158)
    at org.jetbrains.kotlin.resolve.BodyResolver.resolveFunctionBody(BodyResolver.java:916)
    at org.jetbrains.kotlin.resolve.BodyResolver.resolveFunctionBody(BodyResolver.java:865)
    at org.jetbrains.kotlin.resolve.BodyResolver.resolveFunctionBodies(BodyResolver.java:851)
    at org.jetbrains.kotlin.resolve.BodyResolver.resolveBehaviorDeclarationBodies(BodyResolver.java:122)
    at org.jetbrains.kotlin.resolve.BodyResolver.resolveBodies(BodyResolver.java:241)
    at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations(LazyTopDownAnalyzer.kt:215)
    at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations$default(LazyTopDownAnalyzer.kt:57)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:84)
    at com.android.tools.lint.KotlinLintAnalyzerFacade.analyzePsi(KotlinLintAnalyzerFacade.kt:208)
    at com.android.tools.lint.KotlinLintAnalyzerFacade.analyze(KotlinLintAnalyzerFacade.kt:102)
    at com.android.tools.lint.LintCliClient$LintCliUastParser.prepare(LintCliClient.java:1341)
    at com.android.tools.lint.client.api.UElementVisitor.prepare(UElementVisitor.kt:294)
    at com.android.tools.lint.client.api.LintDriver.visitJavaFiles(LintDriver.kt:1471)
    at com.android.tools.lint.client.api.LintDriver.visitJavaFiles(LintDriver.kt:1445)
    at com.android.tools.lint.client.api.LintDriver.checkJava(LintDriver.kt:1423)
    at com.android.tools.lint.client.api.LintDriver.runFileDetectors(LintDriver.kt:962)
    at com.android.tools.lint.client.api.LintDriver.checkProject(LintDriver.kt:812)
    at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.kt:345)
    at com.android.tools.lint.LintCliClient.run(LintCliClient.java:179)
    at com.android.tools.lint.gradle.LintGradleClient.run(LintGradleClient.java:254)
    at com.android.tools.lint.gradle.LintGradleExecution.runLint(LintGradleExecution.java:257)
    at com.android.tools.lint.gradle.LintGradleExecution.lintAllVariants(LintGradleExecution.java:392)
    at com.android.tools.lint.gradle.LintGradleExecution.analyze(LintGradleExecution.java:98)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.android.tools.lint.gradle.api.ReflectiveLintRunner.runLint(ReflectiveLintRunner.kt:38)
    at com.android.build.gradle.tasks.LintBaseTask.runLint(LintBaseTask.java:87)
    at com.android.build.gradle.tasks.LintGlobalTask.lint(LintGlobalTask.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:780)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:747)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
    at com.intellij.lang.impl.MarkerPool.allocateStartMarker(MarkerPool.java:40)
    at com.intellij.lang.impl.PsiBuilderImpl.createMarker(PsiBuilderImpl.java:829)
    at com.intellij.lang.impl.PsiBuilderImpl.mark(PsiBuilderImpl.java:822)
    at com.intellij.lang.impl.PsiBuilderAdapter.mark(PsiBuilderAdapter.java:107)
    at org.jetbrains.kotlin.parsing.AbstractKotlinParsing.mark(AbstractKotlinParsing.java:73)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parsePostfixExpression(KotlinExpressionParsing.java:438)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parsePrefixExpression(KotlinExpressionParsing.java:367)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$200(KotlinExpressionParsing.java:41)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing$Precedence$2.parseHigherPrecedence(KotlinExpressionParsing.java:165)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression(KotlinExpressionParsing.java:312)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$300(KotlinExpressionParsing.java:41)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing$Precedence.parseHigherPrecedence(KotlinExpressionParsing.java:210)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression(KotlinExpressionParsing.java:312)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$300(KotlinExpressionParsing.java:41)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing$Precedence.parseHigherPrecedence(KotlinExpressionParsing.java:210)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression(KotlinExpressionParsing.java:312)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$300(KotlinExpressionParsing.java:41)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing$Precedence.parseHigherPrecedence(KotlinExpressionParsing.java:210)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression(KotlinExpressionParsing.java:312)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$300(KotlinExpressionParsing.java:41)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing$Precedence.parseHigherPrecedence(KotlinExpressionParsing.java:210)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression(KotlinExpressionParsing.java:312)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$300(KotlinExpressionParsing.java:41)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing$Precedence.parseHigherPrecedence(KotlinExpressionParsing.java:210)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression(KotlinExpressionParsing.java:312)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$300(KotlinExpressionParsing.java:41)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing$Precedence.parseHigherPrecedence(KotlinExpressionParsing.java:210)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression(KotlinExpressionParsing.java:312)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$300(KotlinExpressionParsing.java:41)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing$Precedence.parseHigherPrecedence(KotlinExpressionParsing.java:210)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.parseBinaryExpression(KotlinExpressionParsing.java:312)
    at org.jetbrains.kotlin.parsing.KotlinExpressionParsing.access$300(KotlinExpressionParsing.java:41)

javax.imageio.ImageIO.write报空指针异常,发现是没有路径directory导致

1.加入路径存在判断即可

        File directory = new File(bashPath + pinyin);
        if(!directory.exists()){
            directory.mkdir();
        }

2.完整报错:

java.lang.NullPointerException: null
    at javax.imageio.ImageIO.write(ImageIO.java:1538) ~[na:1.8.0_212]
    at com.tddlmj.rstar.controller.SpiderController.saveImage(SpiderController.java:143) ~[classes/:na]
    at com.tddlmj.rstar.controller.SpiderController.saveImg(SpiderController.java:109) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_212]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_212]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_212]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_212]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:634) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) ~[spring-webmvc-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200) ~[tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.17.jar:9.0.17]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]

h2内置的tool可以备份还原h2数据库。

1.首先引入了h2的依赖,注意scope是compile,spring boot 默认是runtime,没法使用

  <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>compile</scope>
        </dependency>

2.要使用文件数据库,内存数据库貌似不行,

spring.datasource.url=jdbc:h2:file:~/db/mydb
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.hibernate.ddl-auto=update

3.java 代码

import org.h2.tools.Backup;
import org.h2.tools.Restore;
@RequestMapping("/bak")
    public String bak() throws Exception {
        String file = "~/db/bak/backup-" + JodaDateUtil.formatDate(JodaDateUtil.set000000(new Date()), "yyyy-MM-dd") + ".zip";

        Backup.execute(file, "~/db", "mydb", true);
        return "0k";
    }

    @RequestMapping("/res")
    public String res() throws Exception {
        String file = "~/db/bak/backup-" + JodaDateUtil.formatDate(JodaDateUtil.set000000(new Date()), "yyyy-MM-dd") + ".zip";
        File f = new File(file);
        int i = 1;
        while (!f.exists()) {
            DateTime d = new DateTime();
            d.minusDays(i);
            file = "~/db/bak/backup-" + JodaDateUtil.formatDate(JodaDateUtil.set000000(d.toDate()), "yyyy-MM-dd") + ".zip";
            f = new File(file);
            i++;
        }
        Restore.execute(file, "~/db", "mydb");
        return "0k";
    }

这个是linux机器,建议使用kvm来虚拟运行安卓app.
我的是archlinux

首先最首要的一点,bios中开启intel Virtualization Technology ----enable。。

如果这个开启后不行了,再做下面的操作

1.检查是否支持虚拟化,0表示不支持

$:LC_ALL=C lscpu | grep Virtualization
Virtualization:      VT-x

2.是否核心支持kvm

$ zgrep CONFIG_KVM /proc/config.gz
CONFIG_KVM_GUEST=y
# CONFIG_KVM_DEBUG_FS is not set
CONFIG_KVM_MMIO=y
CONFIG_KVM_ASYNC_PF=y
CONFIG_KVM_VFIO=y
CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y
CONFIG_KVM_COMPAT=y
CONFIG_KVM=m
CONFIG_KVM_INTEL=m
CONFIG_KVM_AMD=m
CONFIG_KVM_AMD_SEV=y
CONFIG_KVM_MMU_AUDIT=y

3.安装kvm

#加载内核虚拟化模块
 sudo modprobe virtio
#kvm 
sudo pacman -S  qemu  libvirt 
#如果需要图形及面
sudo pacman -S virt-manager
#连接网络需要的包
sudo pacman -S ebtables dnsmasq bridge-utils openbsd-netcat
# 当前用户加入组kvm
$ sudo usermod -a -G kvm shenfeng