首页 » Latest Post

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)

linux 转发端口8000 到169.254.0.77的8000 端口,但是必须使用10.10.4.16这个跳板,那么连接如下

1.转发

ssh -L 8000:169.254.0.77:8000 10.10.4.16 -l root

2.测试

telnet 127.0.0.1 8000

archlinux 可以用iptables转发端口,比如我是把自己的端口8000 转发10.10.4.16:8000

1.下载安装iptables

sudo pacman -S iptables

2.启用端口转发,需要root权限

sudo -i
echo 1 > /proc/sys/net/ipv4/ip_forward

3.配置iptalbes转发

iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 8000 -j DNAT --to 169.254.0.77:8000

sudo -i
iptables-save > /etc/iptables/iptables.rules #保存规则到默认文件
exit

systemctl enable iptables
systemctl restart iptables 
iptables -t nat -nvL

4.如果错误清空:

iptables -t nat -F # reset
iptables-save > /etc/iptables/iptables.rules #保存规则到默认文件=

5.参考https://wiki.archlinux.org/index.php/iptables