问:
Why does intellij run SpringBootApplication fine while packed jar wont find resources?
I have a simple POST form using Springboot/gradle/java. What i cant understand is why when i right click and hit run from intellij the app finds the index page, no issue. But when i package as a jar it won't find the index page. i can type it manually, but then i get weird issues when actually doing the post so i'm trying to fix the first issue first...

this is my main:

```<code>import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication

@SpringBootApplication
class HandlingRewardsFormSubmission{
    static void main(String[] args) {
        SpringApplication.run(HandlingRewardsFormSubmission.class, args)
    }
}
</code>```

My controller

```<code>import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PostMapping

@Controller
class RewardsDataController {
    @GetMapping("/")
    String index(Model model){
        return "index"
    }
</code>```

Dir structure

```<code>src
-main
-resources
-application.properties
--META-INF
---MANIFEST.MF
--templates
---index.html
</code>```

I have tried moving the web resource directories around (/,resources/,resources/templates/ etc) to no avail because of this error message but i question why must i have a template resolver when i have all the default settings according to the spring tutorials:

```<code>08:28:15.370 [reactor-http-nio-2] DEBUG org.thymeleaf.spring5.view.reactive.ThymeleafReactiveView - [f3e264cf] View name 'index', model {thymeleafWebSession=MonoCacheTime}
08:28:15.400 [boundedElastic-1] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][boundedElastic-1] Exception processing template "index": Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
    at org.thymeleaf.spring5.SpringWebFluxTemplateEngine.lambda$createFullStream$0(SpringWebFluxTemplateEngine.java:212)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1637)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:147)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.ignoreDone(MonoIgnoreThen.java:190)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreInner.onComplete(MonoIgnoreThen.java:240)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
    at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1679)
    at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:314)
    at reactor.core.publisher.MonoWhen$WhenCoordinator.signal(MonoWhen.java:208)
    at reactor.core.publisher.MonoWhen$WhenInner.onComplete(MonoWhen.java:285)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1638)
    at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.signalCached(MonoCacheTime.java:320)
    at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.onNext(MonoCacheTime.java:337)
    at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192)
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:249)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
08:28:15.401 [boundedElastic-1] ERROR org.thymeleaf.spring5.SpringWebFluxTemplateEngine - [THYMELEAF][boundedElastic-1] Exception processing template "index": Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
    at org.thymeleaf.spring5.SpringWebFluxTemplateEngine.lambda$createFullStream$0(SpringWebFluxTemplateEngine.java:212)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1637)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:147)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.ignoreDone(MonoIgnoreThen.java:190)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreInner.onComplete(MonoIgnoreThen.java:240)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
    at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1679)
    at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:314)
    at reactor.core.publisher.MonoWhen$WhenCoordinator.signal(MonoWhen.java:208)
    at reactor.core.publisher.MonoWhen$WhenInner.onComplete(MonoWhen.java:285)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1638)
    at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.signalCached(MonoCacheTime.java:320)
    at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.onNext(MonoCacheTime.java:337)
    at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192)
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:249)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
08:28:15.443 [boundedElastic-1] DEBUG org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler - [f3e264cf] Resolved [TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers] for HTTP GET /
08:28:15.443 [boundedElastic-1] ERROR org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler - [f3e264cf]  500 Server Error for HTTP GET "/"
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
    |_ checkpoint ? Handler co.za.ebucks.RewardsDataController#index(Model) [DispatcherHandler]
    |_ checkpoint ? HTTP GET "/" [ExceptionHandlingWebHandler]
Stack trace:
        at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
        at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
        at org.thymeleaf.spring5.SpringWebFluxTemplateEngine.lambda$createFullStream$0(SpringWebFluxTemplateEngine.java:212)
        at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55)
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1637)
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:147)
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.ignoreDone(MonoIgnoreThen.java:190)
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreInner.onComplete(MonoIgnoreThen.java:240)
        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
        at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1679)
        at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:314)
        at reactor.core.publisher.MonoWhen$WhenCoordinator.signal(MonoWhen.java:208)
        at reactor.core.publisher.MonoWhen$WhenInner.onComplete(MonoWhen.java:285)
        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1638)
        at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.signalCached(MonoCacheTime.java:320)
        at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.onNext(MonoCacheTime.java:337)
        at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192)
        at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
        at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:249)
        at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
        at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
</code>```

oh and my gradle file:

```<code>plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'war'
    id 'groovy'
//    id 'java'
}
war {
    enabled = true
}
jar {
    manifest {
        attributes 'Main-Class': 'co.za.ebucks.HandlingRewardsFormSubmission'
    }
}
group = 'co.za.ebucks'
version = '1.0.0'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}
ext {
    seleniumVersion = '3.141.59'
}
configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}
test {
    useTestNG()
}

dependencies {
//    compile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
    implementation 'org.springframework.boot:spring-boot-starter-tomcat'
    compile group: 'org.apache.tomcat', name: 'tomcat-catalina', version: '9.0.31'

    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    implementation 'org.springframework.session:spring-session-core'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

    implementation group: 'org.codehaus.groovy', name: 'groovy-all', version: '3.0.0'
    implementation group: 'com.google.inject', name: 'guice', version: '4.2.2'
    implementation group: 'com.google.guava', name: 'guava', version: '28.1-jre'
    implementation group: 'cglib', name: 'cglib', version: '3.3.0'
    implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.10'

    testImplementation group: 'org.testng', name: 'testng', version: '7.1.0'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation "org.seleniumhq.selenium:selenium-support:${seleniumVersion}"
    testImplementation group: 'io.appium', name: 'java-client', version: '7.3.0'
    testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: "${seleniumVersion}"
    testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-server', version: "${seleniumVersion}"
    testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: "${seleniumVersion}"
    testImplementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.0'
    testImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.0'

    developmentOnly 'org.springframework.boot:spring-boot-devtools'

}
</code>```

答:
I feel sooo stupid right now. Please excuse me this is my first time using spring, and my first time setting up a website in over 15 years.

The issue was nothing with the above but with the way how to configure web facet resources. the `src/main/resources/' directory should have been the root path '/' of the web resource directory. Not the most obvious of things to me :(

Body:
I have a simple POST form using Springboot/gradle/java. What i cant understand is why when i right click and hit run from intellij the app finds the index page, no issue. But when i package as a jar it won't find the index page. i can type it manually, but then i get weird issues when actually doing the post so i'm trying to fix the first issue first...

this is my main:

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication

@SpringBootApplication
class HandlingRewardsFormSubmission{
    static void main(String[] args) {
        SpringApplication.run(HandlingRewardsFormSubmission.class, args)
    }
}

My controller

import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.ModelAttribute
import org.springframework.web.bind.annotation.PostMapping

@Controller
class RewardsDataController {
    @GetMapping("/")
    String index(Model model){
        return "index"
    }

Dir structure

src
-main
-resources
-application.properties
--META-INF
---MANIFEST.MF
--templates
---index.html

I have tried moving the web resource directories around (/,resources/,resources/templates/ etc) to no avail because of this error message but i question why must i have a template resolver when i have all the default settings according to the spring tutorials:

08:28:15.370 [reactor-http-nio-2] DEBUG org.thymeleaf.spring5.view.reactive.ThymeleafReactiveView - [f3e264cf] View name 'index', model {thymeleafWebSession=MonoCacheTime}
08:28:15.400 [boundedElastic-1] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][boundedElastic-1] Exception processing template "index": Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
    at org.thymeleaf.spring5.SpringWebFluxTemplateEngine.lambda$createFullStream$0(SpringWebFluxTemplateEngine.java:212)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1637)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:147)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.ignoreDone(MonoIgnoreThen.java:190)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreInner.onComplete(MonoIgnoreThen.java:240)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
    at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1679)
    at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:314)
    at reactor.core.publisher.MonoWhen$WhenCoordinator.signal(MonoWhen.java:208)
    at reactor.core.publisher.MonoWhen$WhenInner.onComplete(MonoWhen.java:285)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1638)
    at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.signalCached(MonoCacheTime.java:320)
    at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.onNext(MonoCacheTime.java:337)
    at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192)
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:249)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
08:28:15.401 [boundedElastic-1] ERROR org.thymeleaf.spring5.SpringWebFluxTemplateEngine - [THYMELEAF][boundedElastic-1] Exception processing template "index": Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
    at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
    at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
    at org.thymeleaf.spring5.SpringWebFluxTemplateEngine.lambda$createFullStream$0(SpringWebFluxTemplateEngine.java:212)
    at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
    at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55)
    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1637)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:147)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.ignoreDone(MonoIgnoreThen.java:190)
    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreInner.onComplete(MonoIgnoreThen.java:240)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
    at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1679)
    at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:314)
    at reactor.core.publisher.MonoWhen$WhenCoordinator.signal(MonoWhen.java:208)
    at reactor.core.publisher.MonoWhen$WhenInner.onComplete(MonoWhen.java:285)
    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
    at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1638)
    at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.signalCached(MonoCacheTime.java:320)
    at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.onNext(MonoCacheTime.java:337)
    at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192)
    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
    at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
    at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:249)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
    at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
08:28:15.443 [boundedElastic-1] DEBUG org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler - [f3e264cf] Resolved [TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers] for HTTP GET /
08:28:15.443 [boundedElastic-1] ERROR org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler - [f3e264cf]  500 Server Error for HTTP GET "/"
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [index], template might not exist or might not be accessible by any of the configured Template Resolvers
    at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
    Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
    |_ checkpoint ? Handler co.za.ebucks.RewardsDataController#index(Model) [DispatcherHandler]
    |_ checkpoint ? HTTP GET "/" [ExceptionHandlingWebHandler]
Stack trace:
        at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
        at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098)
        at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072)
        at org.thymeleaf.spring5.SpringWebFluxTemplateEngine.lambda$createFullStream$0(SpringWebFluxTemplateEngine.java:212)
        at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:57)
        at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:55)
        at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:150)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1637)
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.drain(MonoIgnoreThen.java:147)
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.ignoreDone(MonoIgnoreThen.java:190)
        at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreInner.onComplete(MonoIgnoreThen.java:240)
        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
        at reactor.core.publisher.Operators$MonoSubscriber.onComplete(Operators.java:1679)
        at reactor.core.publisher.MonoIgnoreThen$ThenAcceptInner.onComplete(MonoIgnoreThen.java:314)
        at reactor.core.publisher.MonoWhen$WhenCoordinator.signal(MonoWhen.java:208)
        at reactor.core.publisher.MonoWhen$WhenInner.onComplete(MonoWhen.java:285)
        at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onComplete(MonoPeekTerminal.java:292)
        at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1638)
        at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.signalCached(MonoCacheTime.java:320)
        at reactor.core.publisher.MonoCacheTime$CoordinatorSubscriber.onNext(MonoCacheTime.java:337)
        at reactor.core.publisher.FluxPeek$PeekSubscriber.onNext(FluxPeek.java:192)
        at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67)
        at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:121)
        at reactor.core.publisher.FluxSubscribeOnCallable$CallableSubscribeOnSubscription.run(FluxSubscribeOnCallable.java:249)
        at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:68)
        at reactor.core.scheduler.SchedulerTask.call(SchedulerTask.java:28)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

oh and my gradle file:

plugins {
    id 'org.springframework.boot' version '2.2.4.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'war'
    id 'groovy'
//    id 'java'
}
war {
    enabled = true
}
jar {
    manifest {
        attributes 'Main-Class': 'co.za.ebucks.HandlingRewardsFormSubmission'
    }
}
group = 'co.za.ebucks'
version = '1.0.0'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}
ext {
    seleniumVersion = '3.141.59'
}
configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}
test {
    useTestNG()
}

dependencies {
//    compile group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
    implementation 'org.springframework.boot:spring-boot-starter-tomcat'
    compile group: 'org.apache.tomcat', name: 'tomcat-catalina', version: '9.0.31'

    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-webflux'
    implementation 'org.springframework.session:spring-session-core'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

    implementation group: 'org.codehaus.groovy', name: 'groovy-all', version: '3.0.0'
    implementation group: 'com.google.inject', name: 'guice', version: '4.2.2'
    implementation group: 'com.google.guava', name: 'guava', version: '28.1-jre'
    implementation group: 'cglib', name: 'cglib', version: '3.3.0'
    implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.10'

    testImplementation group: 'org.testng', name: 'testng', version: '7.1.0'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation "org.seleniumhq.selenium:selenium-support:${seleniumVersion}"
    testImplementation group: 'io.appium', name: 'java-client', version: '7.3.0'
    testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: "${seleniumVersion}"
    testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-server', version: "${seleniumVersion}"
    testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-chrome-driver', version: "${seleniumVersion}"
    testImplementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.0'
    testImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.0'

    developmentOnly 'org.springframework.boot:spring-boot-devtools'

}


来源: stackexchange

问:
PlatformIO Possible key upload_flags & upload_command string option
I work with STM32F429ZI and PlatformIO and i need to upload firmware to specific address like 0x08020000 for example. And I can't find in docs on platformio which key for upload_flags I can use for it, or how I can modify upload_command for it. Thanks.</p>

答:
Right solution is add mbed_app.json to your project root with:

```<code>{
    "target_overrides": {
        "*": {
        "target.mbed_app_start" : "0x08020000",
        "target.mbed_app_size" :  "0x000A0000"
        }
    }
}
</code>```

https://os.mbed.com/docs/mbed-os/v5.15/reference/bootloader-configuration.html

This parameters expand to:

```<code>MEMORY
{
  FLASH (rx) : ORIGIN = 0x8020000, LENGTH = 0xa0000
...
}
</code>```

on your .ld script and you don't need to change upload_flags and upload_command.

ContentLicense: CC BY-SA 4.0

Body:
Right solution is add mbed_app.json to your project root with:

{
    "target_overrides": {
        "*": {
        "target.mbed_app_start" : "0x08020000",
        "target.mbed_app_size" :  "0x000A0000"
        }
    }
}

https://os.mbed.com/docs/mbed-os/v5.15/reference/bootloader-configuration.html

This parameters expand to:

MEMORY
{
  FLASH (rx) : ORIGIN = 0x8020000, LENGTH = 0xa0000
...
}

on your .ld script and you don't need to change upload_flags and upload_command.


问:
Failing to display image from server directory file
I'm failing to display the contents of "uploads" folder.

On the website I've uploaded the image and it goes into the server directory file/ the uploads folder, and then it should fetch and display the image, but it doesn't. Thanks for reading this, I'm happy to hear your suggestions.

```<code>    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
    $uploadOk = 1;
    $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

//This is me trying to display the image (all this is in the index.file <main> where my server.php file is included (<?php require_once 'server.php'; ?>)) -
    <td><?php echo '<img src="'.$target_dir.'" width="100" height="100">'; ?></td>

<main>
<?php require_once 'edit-carteri-server.php'; ?>

<?php

if (isset($_SESSION['message'])): ?>

<div class="alert alert-<?=$_SESSION['msg_type']?>">

    <?php
        echo $_SESSION['message'];
        unset($_SESSION['message']);
    ?>
</div>
<?php endif ?>

<div class="container">
<?php
    $mysqli = new mysqli('localhost', 'root', '', 'id12522465_admin') or die(mysqli_error($mysqli));        //Savieno ar datubāzi
    $result = $mysqli->query("SELECT * FROM carteri") or die($mysqli->error);
 ?>

<div class="row justify-content-center">
    <table class="table">
        <thead>
            <tr>
                <th>Bilde</th>
                <th>Valsts</th>
                <th>Teksts</th>
                <th colspan="2">Action</th>
            </tr>
<?php

    while ($row = $result->fetch_assoc()): ?>
        <tr>
            <td><?php echo '<img src="'.$target_file.'" width="100" height="100">'; ?></td>
            <td><?php echo $row['valsts']; ?></td>
            <td><?php echo $row['teksts']; ?></td>
            <td>
                <a href="edit-carteri.php?edit=<?php echo $row['id']; ?>"
                    class="btn btn-info">Edit</a>
                <a href="edit-carteri-server.php?delete=<?php echo $row['id']; ?>"
                    class="btn btn-danger">Delete</a>
            </td>
        </tr>
<?php endwhile; ?>
        </thead>
    </table>
</div>
</code>```

答:
From the code snippet there it looks like you may just be using the wrong variable, unless that was a mistake in adding the question.

Should be $target_file instead of $target_dir in the image tag:

```<code><td><?php echo '<img src="'.$target_file .'" width="100" height="100">'; ?></td>
</code>```

Body:
I'm failing to display the contents of "uploads" folder.

On the website I've uploaded the image and it goes into the server directory file/ the uploads folder, and then it should fetch and display the image, but it doesn't. Thanks for reading this, I'm happy to hear your suggestions.

    $target_dir = "uploads/";
    $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
    $uploadOk = 1;
    $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

//This is me trying to display the image (all this is in the index.file  where my server.php file is included (<?php require_once 'server.php'; ?>)) -
    <?php echo ''; ?>

<?php require_once 'edit-carteri-server.php'; ?>

<?php

if (isset($_SESSION['message'])): ?>

<div class="alert alert-<?=$_SESSION['msg_type']?>">

    <?php
        echo $_SESSION['message'];
        unset($_SESSION['message']);
    ?>

<?php endif ?>

<?php
    $mysqli = new mysqli('localhost', 'root', '', 'id12522465_admin') or die(mysqli_error($mysqli));        //Savieno ar datubāzi
    $result = $mysqli->query("SELECT * FROM carteri") or die($mysqli->error);
 ?>

                Bilde
                Valsts
                Teksts
                Action

<?php

    while ($row = $result->fetch_assoc()): ?>

            <?php echo ''; ?>
            <?php echo $row['valsts']; ?>
            <?php echo $row['teksts']; ?>

                <a href="edit-carteri.php?edit=<?php echo $row['id']; ?>"
                    class="btn btn-info">Edit
                <a href="edit-carteri-server.php?delete=<?php echo $row['id']; ?>"
                    class="btn btn-danger">Delete

<?php endwhile; ?>

Body:
From the code snippet there it looks like you may just be using the wrong variable, unless that was a mistake in adding the question.

Should be $target_file instead of $target_dir in the image tag:

<td><?php echo '<img src="'.$target_file .'" width="100" height="100">'; ?></td>


问:
State ReactJS and render method
I'm studying chapter State and lifecycle in reactJS with Clock class and I don't understand why I can re-render my variables "myFirstNumber, mySecondNumber, myWord"  which are not states when I use this code in CodePen:

class Clock extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      date: new Date(),
    };
    this.mySecondNumber = 0;
  }

  componentDidMount() {
    this.myFirstNumber = 0;
    this.myWord = "Start";
    this.timerID = setInterval(
      () => this.tick(),
      1000
    );

  }

  componentWillUnmount() {
    clearInterval(this.timerID);
  }

  tick() {
    this.setState({
      date: new Date(),

    });
        this.myFirstNumber += 1;
       this.mySecondNumber += 1;
    if (this.myFirstNumber ===5) {
      this.myWord = "Finish";
    }
  }

  render() {
    return (

Hello, world!

It is {this.state.date.toLocaleTimeString()}.

myFirstNumber from ComponentDidMount: {this.myFirstNumber}

mySecondNumber from constructor: {this.mySecondNumber}

myWord: {this.myWord}

    );
  }
}

ReactDOM.render(
  <Clock />,
  document.getElementById('root')
);
```

The render method render all DOM each seconde for my variables which are not states ?

答: When you run tick() the setState part is what triggers the re-render and that will process everything, state or not.

Title: State ReactJS and render method

Body:
I'm studying chapter State and lifecycle in reactJS with Clock class and I don't understand why I can re-render my variables "myFirstNumber, mySecondNumber, myWord"  which are not states when I use this code in CodePen:

class Clock extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      date: new Date(),
    };
    this.mySecondNumber = 0;
  }

  componentDidMount() {
    this.myFirstNumber = 0;
    this.myWord = "Start";
    this.timerID = setInterval(
      () => this.tick(),
      1000
    );

  }

  componentWillUnmount() {
    clearInterval(this.timerID);
  }

  tick() {
    this.setState({
      date: new Date(),

    });
        this.myFirstNumber += 1;
       this.mySecondNumber += 1;
    if (this.myFirstNumber ===5) {
      this.myWord = "Finish";
    }
  }

  render() {
    return (

Hello, world!

It is {this.state.date.toLocaleTimeString()}.

myFirstNumber from ComponentDidMount: {this.myFirstNumber}

mySecondNumber from constructor: {this.mySecondNumber}

myWord: {this.myWord}

    );
  }
}

ReactDOM.render(
  <Clock />,
  document.getElementById('root')
);

The render method render all DOM each seconde for my variables which are not states ?


问:
How to paste vector into empty cells of a dataframe column that are not NA in R?
I have a vector of data that looks like this:

```<code>data_vector <– c("dgh4s", "suc8ec", "sc8cjsn")
</code>```

I want to paste the values of the vector in order into a column of a dataframe that looks like this:

```<code>df$vector2 <– c("", NA, "", "", NA)
</code>```

So my desired output is:

```<code>df$vector2 <– c("dgh4s", NA, "suc8ec", "sc8cjsn", NA)
</code>```

I've searched stackoverflow but I can't quite figure out how to do this? Any ideas?

Thank you in advance for your help!

答:
For this type, we can use str_c instead of paste as str_c returns NA wherever there is an NA

```<code>library(stringr)
str_c(data_vector, df$vector2)
</code>```

Body:
I have a vector of data that looks like this:

data_vector <– c("dgh4s", "suc8ec", "sc8cjsn")

I want to paste the values of the vector in order into a column of a dataframe that looks like this:

df$vector2 <– c("", NA, "", "", NA)

So my desired output is:

df$vector2 <– c("dgh4s", NA, "suc8ec", "sc8cjsn", NA)

I've searched stackoverflow but I can't quite figure out how to do this? Any ideas?

Thank you in advance for your help!

Body:
For this type, we can use str_c instead of paste as str_c returns NA wherever there is an NA

library(stringr)
str_c(data_vector, df$vector2)


问:
Get macro value from a compiled binary (with debug)
I need to determine the value of a specific macro the binary was compiled with.

The file is a Linux shared library file.

Is it possible?

答:
Given that macros are handled by a preprocessor, even the actual compiler is not aware of them. The only option is to reverse engineer the cod, find the place where you know the macro is used and extract the value from there.

Edit: I've just checked DWARF specification, the standard defines .debug_macinfo section especially to store debug info about macros, this section contains a DW_MACINFO_define record for each defined macro.

So, if you have a debug version of the library, you can try to use dwarfdump -m or readelf --debug-dump=macro to extract this info.

However: I've tried it on a few libraries in my system, and none of them contained any macro records. By default gcc doesn't emit them, the library has to be compiled with gcc -g3 (the switch increases the debug info level). This is sort of bad news for you, I suppose.

ContentLicense: CC BY-SA 3.0


问:
React Navigation 5, block back navigation after login
I am using React Navigation 5 in a project, and I'm having trouble trying to block a user from navigating back after a certain point.

The app uses a nested navigation structure similar to this:

```<code>ROOT (STACK)
|-- LoginScreens (STACK - options={{ gestureEnabled: false }} )
|   |-- Login (SCREEN) -> when successful navigate to "Home"
|   +-- Register (SCREEN) -> after registration, navigate to "Login"
|
+-- Home (TABS - options={{ gestureEnabled: false }} )
    |-- BlahBlah (SCREEN)
    |-- MyProfile (SCREEN)
    +-- Dashboard (TABS)
        |-- AllTasks (SCREEN)
        +-- SomethingElse (SCREEN)
</code>```

After a successful user login, the user is sent to the Home screen and should not be able to navigate back to the LoginScreens screen.

I have tried to use the componentDidMount lifecycle method on Home, as well as the useFocusEffect hook, with the following:

Placing a callback to React Native's BackHandler, returning true from the handler works (true means back action has been handled, no further back handlers will be called), but it will also block any back navigation within the screens in Home (e.g. I cannot navigate back from Dashboard to MyProfile).

Using navigation.reset({ index: 1, routes: [{ name: "Home" }] }). Without index: 1 the navigation just goes back to ROOT's initialRoute (in this case, LoginScreens). With index: 1, a Maximum update depth exceeded error is thrown.

Instead navigating directly to Home, I have tried using a navigation.reset() (note: no params, clears the entire navigation history), and after that navigate to the Home screen. This doesn't achieve the desired effect since the current route (ROOT's initialRoute, in this case: LoginScreens) is still pushed on the navigation history before navigating to Home.

Combining navigation and reset calls in different ways, I have only managed to get JS angry and throw errors and exceptions at me.

Aaaaand... I have ran out of ideas. Does anyone have any suggestions ?

答:
It seems that React Navigation's docs tried to cover this use case with this guide:

https://reactnavigation.org/docs/en/auth-flow.html

The example there is very tricky, already introduces state management libraries, reducers, React hooks, and whatever else that doesn't really help. However, the summary of that guide is: Conditionally render routes.

Unlinke React Navigation 4 and previous versions, in React Navigation 5 you can conditionally render routes. In doing so you effectively rule out any possibilities of navigation to an inexistent route. Below, there is a very short example of how you can do it with a simple state variable. Keep in mind however that this example only takes into account a navigator with one route rendered at a time. If you have more routes that are rendered other than the ones in this example, you may need to adjust the RootStack.Navigator's props (initialRouteName for example), or explicitly navigate to a specific route.

```<code>import React from "react";
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

import LoginNav from "./screens/LoginNav";
import HomeScreens from "./screens/HomeScreens";

const RootStack = createStackNavigator();

export default class MyApp extends React.Component {
    constructor(props){
        super(props);

        this.state = { isLoggedIn: false };
    }

    setIsLoggedIn = (isLoggedIn)=>{ this.setState({ isLoggedIn }); }

    render = () => {
        // Using an arrow function to allow to pass setIsLoggedIn to LoginNav
        // Pass setIsLoggedIn from the props of LoginNav to the screens it contains
        // then from the screens call this function with a true/false param
        const LoginScreens = (props)=> <LoginNav {...props} setIsLoggedIn={this.setIsLoggedIn} />

        return <NavigationContainer style={{ flex: 1 }}>
            <RootStack.Navigator>
                {(this.state.isLoggedIn === false)
                    // If not logged in, the user will be shown this route
                    ? <RootStack.Screen name="LoginScreens" component={LoginScreens} />
                    // When logged in, the user will be shown this route
                    : <RootStack.Screen name="Home" component={HomeScreens} />
                }
            </RootStack.Navigator>
        </NavigationContainer>;
    }
}
</code>```

In this example, call (this.) props.setIsLoggedIn(true) to render the Home route, or call with a false param to return to the LoginScreens route.

Hopefully this example is easier to understand than the one in the docs.

Body:
I am using React Navigation 5 in a project, and I'm having trouble trying to block a user from navigating back after a certain point.

The app uses a nested navigation structure similar to this:

ROOT (STACK)
|-- LoginScreens (STACK - options={{ gestureEnabled: false }} )
|   |-- Login (SCREEN) -> when successful navigate to "Home"
|   +-- Register (SCREEN) -> after registration, navigate to "Login"
|
+-- Home (TABS - options={{ gestureEnabled: false }} )
    |-- BlahBlah (SCREEN)
    |-- MyProfile (SCREEN)
    +-- Dashboard (TABS)
        |-- AllTasks (SCREEN)
        +-- SomethingElse (SCREEN)

After a successful user login, the user is sent to the Home screen and should not be able to navigate back to the LoginScreens screen.

I have tried to use the componentDidMount lifecycle method on Home, as well as the useFocusEffect hook, with the following:

Placing a callback to React Native's BackHandler, returning true from the handler works (true means back action has been handled, no further back handlers will be called), but it will also block any back navigation within the screens in Home (e.g. I cannot navigate back from Dashboard to MyProfile).

Using navigation.reset({ index: 1, routes: [{ name: "Home" }] }). Without index: 1 the navigation just goes back to ROOT's initialRoute (in this case, LoginScreens). With index: 1, a Maximum update depth exceeded error is thrown.

Instead navigating directly to Home, I have tried using a navigation.reset() (note: no params, clears the entire navigation history), and after that navigate to the Home screen. This doesn't achieve the desired effect since the current route (ROOT's initialRoute, in this case: LoginScreens) is still pushed on the navigation history before navigating to Home.

Combining navigation and reset calls in different ways, I have only managed to get JS angry and throw errors and exceptions at me.

Aaaaand... I have ran out of ideas. Does anyone have any suggestions ?

Body:
It seems that React Navigation's docs tried to cover this use case with this guide:

https://reactnavigation.org/docs/en/auth-flow.html

The example there is very tricky, already introduces state management libraries, reducers, React hooks, and whatever else that doesn't really help. However, the summary of that guide is: Conditionally render routes.

Unlinke React Navigation 4 and previous versions, in React Navigation 5 you can conditionally render routes. In doing so you effectively rule out any possibilities of navigation to an inexistent route. Below, there is a very short example of how you can do it with a simple state variable. Keep in mind however that this example only takes into account a navigator with one route rendered at a time. If you have more routes that are rendered other than the ones in this example, you may need to adjust the RootStack.Navigator's props (initialRouteName for example), or explicitly navigate to a specific route.

import React from "react";
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';

import LoginNav from "./screens/LoginNav";
import HomeScreens from "./screens/HomeScreens";

const RootStack = createStackNavigator();

export default class MyApp extends React.Component {
    constructor(props){
        super(props);

        this.state = { isLoggedIn: false };
    }

    setIsLoggedIn = (isLoggedIn)=>{ this.setState({ isLoggedIn }); }

    render = () => {
        // Using an arrow function to allow to pass setIsLoggedIn to LoginNav
        // Pass setIsLoggedIn from the props of LoginNav to the screens it contains
        // then from the screens call this function with a true/false param
        const LoginScreens = (props)=> <LoginNav {...props} setIsLoggedIn={this.setIsLoggedIn} />

        return <NavigationContainer style={{ flex: 1 }}>
            <RootStack.Navigator>
                {(this.state.isLoggedIn === false)
                    // If not logged in, the user will be shown this route
                    ? <RootStack.Screen name="LoginScreens" component={LoginScreens} />
                    // When logged in, the user will be shown this route
                    : <RootStack.Screen name="Home" component={HomeScreens} />
                }
            </RootStack.Navigator>
        </NavigationContainer>;
    }
}

In this example, call (this.) props.setIsLoggedIn(true) to render the Home route, or call with a false param to return to the LoginScreens route.

Hopefully this example is easier to understand than the one in the docs.


问:
How can i make first letter of all words in a string uppercase recursively?
I wonder how can i make this. I don't want any iteration or isalpha() and toupper() functions. We want to use our own code to read input. We assume that user enters all characters lowercase. This is what i've tried so far:

```<code>define MAX_LENGTH 100

int read_line(char str[],int);
void capitalize(char[]);

int main (void){
    char A[MAX_LENGTH];
printf("Enter a text \n");
read_line(A, MAX_LENGTH);

capitalize(A);
puts(A);

}

int read_line(char str[],int n){
    int ch,i=0;

    while ((ch = getchar()) != '\n'){
        if(i<MAX_LENGTH)
            str[i++] = ch;
    }
    str[i] = '\0';
    return i;
}

void capitalize(char str[]){
 int x = strlen(str);
 static int i = 0;
    if(str[i]=='\0')
    return;
    if(str[i-1]==' '|| i == 0)
      str[i] -= 32;
      i++;
      return capitalize(&str[i]);
 }
</code>```

Output is like this:

Enter a text:

asdf sdf df

Asdf sdf df

What is wrong with my code?

答:
I would write the following:</p>

```<code>void capitalize(char* str) {
    if (! *str) return;      // job done
    *str = toupper(*str);    // capitalize "correctly"
    capitalize(++str);
}
</code>```

Body:
I wonder how can i make this. I don't want any iteration or isalpha() and toupper() functions. We want to use our own code to read input. We assume that user enters all characters lowercase. This is what i've tried so far:

define MAX_LENGTH 100

int read_line(char str[],int);
void capitalize(char[]);

int main (void){
    char A[MAX_LENGTH];
printf("Enter a text \n");
read_line(A, MAX_LENGTH);

capitalize(A);
puts(A);

}

int read_line(char str[],int n){
    int ch,i=0;

    while ((ch = getchar()) != '\n'){
        if(i<MAX_LENGTH)
            str[i++] = ch;
    }
    str[i] = '\0';
    return i;
}

void capitalize(char str[]){
 int x = strlen(str);
 static int i = 0;
    if(str[i]=='\0')
    return;
    if(str[i-1]==' '|| i == 0)
      str[i] -= 32;
      i++;
      return capitalize(&str[i]);
 }

Output is like this:

Enter a text:

asdf sdf df

Asdf sdf df

What is wrong with my code?

Body:
I would write the following:

void capitalize(char* str) {
    if (! *str) return;      // job done
    *str = toupper(*str);    // capitalize "correctly"
    capitalize(++str);
}


问:
Making the configuration available to all classes
I'm writing a small web server, and it takes a configuration file with all sorts of different options: how many threads to run, which class deals which each file extension, which file to display by default and so on and so forth. To represent this, I'm parsing the config file into a Configuration object which contains all these settings, and the main class holds this object.

However, the config data is required on almost every level of the server - classes within classes within classes...

My question is, what is the best practice to use here? Should I give the config as a parameter for many many classes and pass it back and forth? Should I make it a singleton? Is there another solution I don't see?

答:
Although Singletons are no longer favored by many professionals for various reasons - I think there is still a good use case to use a Ssingleton`.

However - ask yourself if the webserver's requirements really require a single common configuration for all aspects of the server. And if yes - how likely are they to change soon?
For example - lets say your server hosts 3 web sites. And now you are asked to put bandwidth limitations on one of them - how will you configure this?

I really favor a good singleton - although you have to mind the whole thread-safety issue when initializing it in a multi-threaded environment (Although it sounds like you won't have this problem as you won't have multiple threads before initializing it.

Keep in mind that singletons live within a ClassLoader and if you have multiple ClassLoaders (e.g. for each .war you load) you will have multiple copies of this "Singleton".

Consider all the aspects of your server, and if it is really simple - A Singleton will save you a lot of headache - and will make the code much more maintainable and readable.
As mentioned already in one or two of the answers - dependency injection is a good alternative to Singletons - they help you make your JUnits easier.

One note about JUnit, I understand (didn't try it yet) that Mockit can allow you to replace an actual implementation during a test run, so you can still create different JUnit test cases for different scenarios without modifying your Singleton to be testable.


问:
How to do conditional query in Laravel
The situation is following.
The table has 2 date fields and last date is nullable.

In this table I want to get the 1st and 2nd records when I pass 2020-02-10 as parameter. That is between start_end and end_date or bigger than start_date if end_date is null.

How to do Laravel eloquent for this. Thank you in advance.

答:
It's kind of ugly, but I think something like that should work

Model::where(function($query) use ($date){
    $query->where('start_date', '<=', $date)
        ->where('end_date', '>=',  $date);
})->orWhere(function($query) use ($date) {
    $query->where('start_date', '<=', $date)
        ->whereNull('end_date');
})->get()
```

<p><strong>Edit</strong>
Since you need other condition with it, you need to wrap this condition</p>

<pre class="lang-php prettyprint-override"><code>Model::query()
->where(function($query) use ($date) {
    $query->where(function($query) use ($date){
        $query->where('start_date', '<=', $date)
            ->where('end_date', '>=',  $date);
    })->orWhere(function($query) use ($date) {
        $query->where('start_date', '<=', $date)
            ->whereNull('end_date');
    })
})
->where('another_column', true)
->get()
```
```

Title: How to do conditional query in Laravel

Body:
It's kind of ugly, but I think something like that should work

Model::where(function($query) use ($date){
    $query->where('start_date', '<=', $date)
        ->where('end_date', '>=',  $date);
})->orWhere(function($query) use ($date) {
    $query->where('start_date', '<=', $date)
        ->whereNull('end_date');
})->get()

Edit
Since you need other condition with it, you need to wrap this condition

Model::query()
->where(function($query) use ($date) {
    $query->where(function($query) use ($date){
        $query->where('start_date', '<=', $date)
            ->where('end_date', '>=',  $date);
    })->orWhere(function($query) use ($date) {
        $query->where('start_date', '<=', $date)
            ->whereNull('end_date');
    })
})
->where('another_column', true)
->get()
```


问:
SQL Server Collation problem (Msg 468, Level 16, State 9) in IF statement
My problem is occurring with a "simple-as-it-gets" IF statement, making the suggested fixes to many similar questions (e.g. Cannot resolve the collation conflict in my query) seemingly useless.

The error message is :

Msg 468, Level 16, State 9, Procedure #XYZ, Line 11

  Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

It's known that the server collation is set to SQL_Latin1_General_CP1_CI_AS.

This query demonstrates the problem :

```<code>-- this procedure (which gets put into tempdb) is called WITHOUT specifying @Choice
CREATE PROCEDURE #XYZ
(
    -- all other parameters removed (none of them have default values)
    @Choice AS NVARCHAR(1) = 'Y'
)
AS
BEGIN
    IF (@choice = 'Y')  -- error raised here
    BEGIN
        DECLARE @NULL_STATEMENT AS int -- only here because there's no "do nothing" statement
    END
    RETURN
END
</code>```

How can I fix this, given that altering the default collation of the server (and/or all of the tables) is NOT going to happen AND it is impractical to insert "COLLATE DATABASE_DEFAULT" in all queries, tables, etc. (for this solution see https://www.mssqltips.com/sqlservertip/4395/understanding-the-collate-databasedefault-clause-in-sql-server/ and Cannot resolve the collation conflict between temp table and sys.objects).

Closely related links:

Documentation of the COLLATE clause: https://learn.microsoft.com/en-us/sql/t-sql/statements/collations?view=sql-server-2017

A solution that I probably cannot use:  https://www.mssqltips.com/sqlservertip/2901/how-to-change-server-level-collation-for-a-sql-server-instance/

答:
(From the currently accepted answer):

The fix was to change the default parameter from ASCII (varchar) to nvarchar (UTF-8) form

No, that did not fix it. That particular change had no effect since the value was converted to NVARCHAR when the T-SQL was parsed (due to the parameter/variable being NVARCHAR) and this error happens at compile time.

This issue has absolutely nothing to do with NVARCHAR, UTF-8, or even parameter default values.

UTF-8 is not being used here. SQL Server is only seeing UTF-16 as that is what Unicode strings are transferred in by the driver (i.e. the TDS / tabular data stream). And even when using a UTF-8 collation (new in SQL Server 2019), that encoding is only used with VARCHAR types as NVARCHAR is only ever UTF-16 (Little Endian).

The issue you ran into is one of several "odd" behaviors found in temporary stored procedures (both local and global). For temporary stored procs, parameters and variables will always have a collation matching the tempdb collation, while string literals will use the collation of the database where the CREATE PROCEDURE statement was executed. These two collations do not change (for the main T-SQL context of the module) even if you use another database that has a different default collation other than [tempdb] and the database where the temporary proc was created (though dynamic SQL executed in a temporary stored procedure will use the current DB's collation! Fun, eh?).

Thus, as Martin Smith said in a comment on the question, you must have changed the "current" / "active" database when executing the CREATE PROCEDURE statement after prefixing the parameter value with N.

The following example is a simplified version of the code shown in the question, but clearly shows that prefixing the string literals with N does not prevent the error.

Execute the following T-SQL in a database that has a different collation than [tempdb]:

-- The two returned collations need to be different, else no error with CREATE PROC:
SELECT DATABASEPROPERTYEX(N'tempdb', 'collation') AS [tempdb collation],
       DATABASEPROPERTYEX(DB_NAME(), 'collation') AS [current DB collation];

SET NOEXEC ON;

GO
CREATE PROCEDURE #XYZ
(
  @Choice NVARCHAR(5) = N'Y'
)
AS
BEGIN
  IF (@Choice = N'Y') PRINT 'yup';
END;
GO

SET NOEXEC OFF;

/*
Msg 468, Level 16, State 9, Procedure #XYZ, Line XXXXX [Batch Start Line YYYYY]
   Cannot resolve the collation conflict between "{current_DB_collation}" and
   "{tempdb_collation}" in the equal to operation.
*/
```

(From the currently accepted answer):

The weird thing is that after running that version I was able to remove the leading N and the query worked without problems.

Correct. That's due to the N prefix not actually having anything to do with the error or fixing it. You were simply in a DB that had a collation of SQL_Latin1_General_CP1_CI_AS which matched the [tempdb] collation.

I'm working on a blog post detailing several odd behaviors with temporary stored procedures, including this collation stuff. If / when I ever finish it, I will try to remember to update this answer with a link to it.

Body:
My problem is occurring with a "simple-as-it-gets" IF statement, making the suggested fixes to many similar questions (e.g. Cannot resolve the collation conflict in my query) seemingly useless.

The error message is :

Msg 468, Level 16, State 9, Procedure #XYZ, Line 11

  Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation.

It's known that the server collation is set to SQL_Latin1_General_CP1_CI_AS.

This query demonstrates the problem :

-- this procedure (which gets put into tempdb) is called WITHOUT specifying @Choice
CREATE PROCEDURE #XYZ
(
    -- all other parameters removed (none of them have default values)
    @Choice AS NVARCHAR(1) = 'Y'
)
AS
BEGIN
    IF (@choice = 'Y')  -- error raised here
    BEGIN
        DECLARE @NULL_STATEMENT AS int -- only here because there's no "do nothing" statement
    END
    RETURN
END

How can I fix this, given that altering the default collation of the server (and/or all of the tables) is NOT going to happen AND it is impractical to insert "COLLATE DATABASE_DEFAULT" in all queries, tables, etc. (for this solution see https://www.mssqltips.com/sqlservertip/4395/understanding-the-collate-databasedefault-clause-in-sql-server/ and Cannot resolve the collation conflict between temp table and sys.objects).

Closely related links:

Documentation of the COLLATE clause: https://learn.microsoft.com/en-us/sql/t-sql/statements/collations?view=sql-server-2017

A solution that I probably cannot use:  https://www.mssqltips.com/sqlservertip/2901/how-to-change-server-level-collation-for-a-sql-server-instance/

Body:
(From the currently accepted answer):

The fix was to change the default parameter from ASCII (varchar) to nvarchar (UTF-8) form

No, that did not fix it. That particular change had no effect since the value was converted to NVARCHAR when the T-SQL was parsed (due to the parameter/variable being NVARCHAR) and this error happens at compile time.

This issue has absolutely nothing to do with NVARCHAR, UTF-8, or even parameter default values.

UTF-8 is not being used here. SQL Server is only seeing UTF-16 as that is what Unicode strings are transferred in by the driver (i.e. the TDS / tabular data stream). And even when using a UTF-8 collation (new in SQL Server 2019), that encoding is only used with VARCHAR types as NVARCHAR is only ever UTF-16 (Little Endian).

The issue you ran into is one of several "odd" behaviors found in temporary stored procedures (both local and global). For temporary stored procs, parameters and variables will always have a collation matching the tempdb collation, while string literals will use the collation of the database where the CREATE PROCEDURE statement was executed. These two collations do not change (for the main T-SQL context of the module) even if you use another database that has a different default collation other than [tempdb] and the database where the temporary proc was created (though dynamic SQL executed in a temporary stored procedure will use the current DB's collation! Fun, eh?).

Thus, as Martin Smith said in a comment on the question, you must have changed the "current" / "active" database when executing the CREATE PROCEDURE statement after prefixing the parameter value with N.

The following example is a simplified version of the code shown in the question, but clearly shows that prefixing the string literals with N does not prevent the error.

Execute the following T-SQL in a database that has a different collation than [tempdb]:

-- The two returned collations need to be different, else no error with CREATE PROC:
SELECT DATABASEPROPERTYEX(N'tempdb', 'collation') AS [tempdb collation],
       DATABASEPROPERTYEX(DB_NAME(), 'collation') AS [current DB collation];

SET NOEXEC ON;

GO
CREATE PROCEDURE #XYZ
(
  @Choice NVARCHAR(5) = N'Y'
)
AS
BEGIN
  IF (@Choice = N'Y') PRINT 'yup';
END;
GO

SET NOEXEC OFF;

/*
Msg 468, Level 16, State 9, Procedure #XYZ, Line XXXXX [Batch Start Line YYYYY]
   Cannot resolve the collation conflict between "{current_DB_collation}" and
   "{tempdb_collation}" in the equal to operation.
*/

(From the currently accepted answer):

The weird thing is that after running that version I was able to remove the leading N and the query worked without problems.

Correct. That's due to the N prefix not actually having anything to do with the error or fixing it. You were simply in a DB that had a collation of SQL_Latin1_General_CP1_CI_AS which matched the [tempdb] collation.

I'm working on a blog post detailing several odd behaviors with temporary stored procedures, including this collation stuff. If / when I ever finish it, I will try to remember to update this answer with a link to it.


问:
CefSharp WPF turn off transparent background
I am using cefsharp version 79.1.360 for WPF.  When ever I create an instance of ChromiumWebBrowser it has a transparent background.  How do I turn this off?</p>

```<code>private void Button_Click(object sender, RoutedEventArgs e)
{
                    ChromiumWebBrowser cwb = new ChromiumWebBrowser();
                    cwb.IsBrowserInitializedChanged += Cwb_IsBrowserInitializedChanged;
}

 private void Cwb_IsBrowserInitializedChanged(object sender, DependencyPropertyChangedEventArgs e)
{
            ChromiumWebBrowser cwb = (ChromiumWebBrowser)sender;
            cwb.Load("url");
}
</code>```

答:
ChromiumWebBrowser's default control template doesn't have any way to set a background color. In my apps, I just put a Border behind the control. Simple.

Otherise, you can override the default style/control template and implement your own.

Body:
I am using cefsharp version 79.1.360 for WPF.  When ever I create an instance of ChromiumWebBrowser it has a transparent background.  How do I turn this off?

private void Button_Click(object sender, RoutedEventArgs e)
{
                    ChromiumWebBrowser cwb = new ChromiumWebBrowser();
                    cwb.IsBrowserInitializedChanged += Cwb_IsBrowserInitializedChanged;
}

 private void Cwb_IsBrowserInitializedChanged(object sender, DependencyPropertyChangedEventArgs e)
{
            ChromiumWebBrowser cwb = (ChromiumWebBrowser)sender;
            cwb.Load("url");
}


问:
list servers OrientDB 2.2. via http rest
i try to get servers status of distributed version of OrientDB via http rest  :

```<code>curl --user admin:admin --header "Accept: text/csv" -d "list servers " "http://localhost:2480/command/GratefulDeadConcerts/sql"
</code>```

doesnt works :

```<code>{
  "errors": [
{
  "code": 500,
  "reason": 500,
  "content": "com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command executor for the command request: sql.list servers\u000d\u000a\u0009DB name=\"GratefulDeadConcerts\""
}
</code>```

答:
Run this command to get the results as JSON that contains all servers (nodes) with detailed status and info per server:</p>

```<code>curl -X POST --user {{user}}:{{password}} --header "Accept: application/json" \
     -d "HA STATUS -servers -db" "{{orientdb-url}}:2480/command/{{database-name}}/sql"
</code>```

Body:
i try to get servers status of distributed version of OrientDB via http rest  :

curl --user admin:admin --header "Accept: text/csv" -d "list servers " "http://localhost:2480/command/GratefulDeadConcerts/sql"

doesnt works :

{
  "errors": [
{
  "code": 500,
  "reason": 500,
  "content": "com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command executor for the command request: sql.list servers\u000d\u000a\u0009DB name=\"GratefulDeadConcerts\""
}

Body:
Run this command to get the results as JSON that contains all servers (nodes) with detailed status and info per server:

curl -X POST --user {{user}}:{{password}} --header "Accept: application/json" \
     -d "HA STATUS -servers -db" "{{orientdb-url}}:2480/command/{{database-name}}/sql"


问:
HDF5 library version error - HDF5 ver 1.10.4
I'm trying to import some packages with spyder (OS x64), Anaconda and pyton 3.x
The error is pretty famous in the internet. The solution proposed is to match the version of the library 1.10.5 with the HDF5 (mine is 1.10.4)

The question is that I can't find HDF5 version 1.10.5
and, the other hand, cannot understand what I could downgrade.

At this link: https://anaconda.org/conda-forge/hdf5 seems exist version 1.10.5 but when I type in the prompt of anaconda conda install -c conda-forge hdf5
the version remain 1.10.4.

Here the warning:

```<code>Warning! ***HDF5 library version mismatched error***
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.10.4, library is 1.10.5
SUMMARY OF THE HDF5 CONFIGURATION
=================================

General Information:
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
HDF5 Version: 1.10.5
Configured on: 2019
Configured by: Visual Studio 15 2017 Win64
Host system: Windows.0.17763
Uname information: Windows
Byte sex: little‑endian
Installation point: C:/Program Files/HDF5

Compiling Options:
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
Build Mode:
Debugging Symbols:
Asserts:
Profiling:
Optimization Level:

Linking Options:
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
Libraries:
Statically Linked Executables: OFF
LDFLAGS: /machine:x64
H5_LDFLAGS:
AM_LDFLAGS:
Extra libraries:
Archiver:
Ranlib:

Languages:
‑‑‑‑‑‑‑‑‑‑
C: yes
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe 19.16.27027.1
CPPFLAGS:
H5_CPPFLAGS:
AM_CPPFLAGS:
CFLAGS: /DWIN32 /D_WINDOWS /W3
H5_CFLAGS:
AM_CFLAGS:
Shared C Library: YES
Static C Library: YES

Fortran: OFF
Fortran Compiler:
Fortran Flags:
H5 Fortran Flags:
AM Fortran Flags:
Shared Fortran Library: YES
Static Fortran Library: YES

C++: ON
C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe 19.16.27027.1
C++ Flags: /DWIN32 /D_WINDOWS /W3 /GR /EHsc
H5 C++ Flags:
AM C++ Flags:
Shared C++ Library: YES
Static C++ Library: YES

JAVA: OFF
JAVA Compiler:

Features:
‑‑‑‑‑‑‑‑‑
Parallel HDF5: OFF
Parallel Filtered Dataset Writes:
Large Parallel I/O:
High‑level library: ON
Threadsafety: OFF
Default API mapping: v110
With deprecated public symbols: ON
I/O filters (external): DEFLATE DECODE ENCODE
MPE:
Direct VFD:
dmalloc:
Packages w/ extra debug output:
API Tracing: OFF
Using memory checker: OFF
Memory allocation sanity checks: OFF
Function Stack Tracing: OFF
Strict File Format Checks: OFF
Optimization Instrumentation:
Bye...
</code>```

Here all the packages installed:

```<code># packages in environment at C:\Users\Megaport\Anaconda3\envs\venv:
#
# Name                    Version                   Build  Channel
_py-xgboost-mutex         2.0                       cpu_0
_tflow_select             2.3.0                       mkl
absl-py                   0.8.0                    pypi_0    pypi
alabaster                 0.7.12                   py37_0
asn1crypto                0.24.0                   py37_0
astor                     0.8.0                    pypi_0    pypi
astroid                   2.2.5                    py37_0
atomicwrites              1.3.0                    py37_1
attrs                     19.1.0                   py37_1
babel                     2.7.0                      py_0
backcall                  0.1.0                    py37_0
blas                      1.0                         mkl
bleach                    3.1.0                    py37_0
ca-certificates           2019.5.15                     1
certifi                   2019.6.16                py37_1
cffi                      1.12.3           py37h7a1dbc1_0
chardet                   3.0.4                 py37_1003
cloudpickle               1.2.1                      py_0
colorama                  0.4.1                    py37_0
cryptography              2.7              py37h7a1dbc1_0
cycler                    0.10.0                   py37_0
decorator                 4.4.0                    py37_1
defusedxml                0.6.0                      py_0
docutils                  0.15.2                   py37_0
entrypoints               0.3                      py37_0
fastcache                 1.1.0            py37he774522_0
freetype                  2.9.1                ha9979f8_1
gast                      0.2.2                    pypi_0    pypi
google-pasta              0.1.7                    pypi_0    pypi
grpcio                    1.23.0                   pypi_0    pypi
h5py                      2.10.0                   pypi_0    pypi
hdf5                      1.10.4               h7ebc959_0
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                 ha66f8fd_1
idna                      2.8                      py37_0
imagesize                 1.1.0                    py37_0
importlib_metadata        0.19                     py37_0
intel-openmp              2019.4                      245
ipykernel                 5.1.2            py37h39e3cac_0
ipython                   7.8.0            py37h39e3cac_0
ipython_genutils          0.2.0                    py37_0
isort                     4.3.21                   py37_0
jedi                      0.15.1                   py37_0
jinja2                    2.10.1                   py37_0
joblib                    0.13.2                   py37_0
jpeg                      9b                   hb83a4c4_2
jsonschema                3.0.2                    py37_0
jupyter_client            5.3.1                      py_0
jupyter_core              4.5.0                      py_0
keras                     2.2.4                         0
keras-applications        1.0.8                      py_0
keras-base                2.2.4                    py37_0
keras-preprocessing       1.1.0                      py_1
keyring                   18.0.0                   py37_0
kiwisolver                1.1.0            py37ha925a31_0
lazy-object-proxy         1.4.2            py37he774522_0
libmklml                  2019.0.5                      0
libpng                    1.6.37               h2a8f88b_0
libprotobuf               3.8.0                h7bd577a_0
libsodium                 1.0.16               h9d3ae62_0
libxgboost                0.90                          0
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  3.1.1                    py37_0
markupsafe                1.1.1            py37he774522_0
matplotlib                3.1.1            py37hc8f65d3_0
mccabe                    0.6.1                    py37_1
mistune                   0.8.4            py37he774522_0
mkl                       2019.4                      245
mkl-service               2.0.2            py37he774522_0
mkl_fft                   1.0.14           py37h14836fe_0
mkl_random                1.0.2            py37h343c172_0
more-itertools            7.2.0                    py37_0
mpmath                    1.1.0                    py37_0
msys2-conda-epoch         20160418                      1
nbconvert                 5.5.0                      py_0
nbformat                  4.4.0                    py37_0
numpy                     1.17.2                   pypi_0    pypi
numpy-base                1.16.4           py37hc3f5095_0
numpydoc                  0.9.1                      py_0
openssl                   1.1.1c               he774522_1
opt-einsum                3.0.1                    pypi_0    pypi
packaging                 19.1                     py37_0
pandas                    0.25.1           py37ha925a31_0
pandoc                    2.2.3.2                       0
pandocfilters             1.4.2                    py37_1
parso                     0.5.1                      py_0
pickleshare               0.7.5                    py37_0
pip                       19.2.2                   py37_0
pluggy                    0.12.0                     py_0
prompt_toolkit            2.0.9                    py37_0
protobuf                  3.9.1                    pypi_0    pypi
psutil                    5.6.3            py37he774522_0
py                        1.8.0                    py37_0
py-xgboost                0.90                     py37_0
py-xgboost-cpu            0.90                     py37_0
pycodestyle               2.5.0                    py37_0
pycparser                 2.19                     py37_0
pyflakes                  2.1.1                    py37_0
pygments                  2.4.2                      py_0
pylint                    2.3.1                    py37_0
pyopenssl                 19.0.0                   py37_0
pyparsing                 2.4.2                      py_0
pyqt                      5.9.2            py37h6538335_2
pyreadline                2.1                      py37_1
pyrsistent                0.14.11          py37he774522_0
pysocks                   1.7.0                    py37_0
pytest                    5.0.1                    py37_0
python                    3.7.4                h5263a28_0
python-dateutil           2.8.0                    py37_0
pytz                      2019.2                     py_0
pywin32                   223              py37hfa6e2cd_1
pyyaml                    5.1.2            py37he774522_0
pyzmq                     18.1.0           py37ha925a31_0
qt                        5.9.7            vc14h73c81de_0
qtawesome                 0.5.7                    py37_1
qtconsole                 4.5.4                      py_0
qtpy                      1.9.0                      py_0
requests                  2.22.0                   py37_0
rope                      0.14.0                     py_0
scikit-learn              0.21.2           py37h6288b17_0
scipy                     1.3.1            py37h29ff71c_0
setuptools                41.2.0                   pypi_0    pypi
sip                       4.19.8           py37h6538335_0
six                       1.12.0                   pypi_0    pypi
snowballstemmer           1.9.0                      py_0
sphinx                    2.1.2                      py_0
sphinxcontrib-applehelp   1.0.1                      py_0
sphinxcontrib-devhelp     1.0.1                      py_0
sphinxcontrib-htmlhelp    1.0.2                      py_0
sphinxcontrib-jsmath      1.0.1                      py_0
sphinxcontrib-qthelp      1.0.2                      py_0
sphinxcontrib-serializinghtml 1.1.3                      py_0
spyder                    3.3.6                    py37_0
spyder-kernels            0.5.1                    py37_0
sqlite                    3.29.0               he774522_0
sympy                     1.4                      py37_0
tb-nightly                1.15.0a20190806          pypi_0    pypi
tensorboard               1.14.0           py37he3c9ec2_0
tensorflow                1.14.0          mkl_py37h7908ca0_0
tensorflow-base           1.14.0          mkl_py37ha978198_0
tensorflow-estimator      1.14.0                     py_0
termcolor                 1.1.0                    pypi_0    pypi
testpath                  0.4.2                    py37_0
tornado                   6.0.3            py37he774522_0
traitlets                 4.3.2                    py37_0
urllib3                   1.24.2                   py37_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_0
wcwidth                   0.1.7                    py37_0
webencodings              0.5.1                    py37_1
werkzeug                  0.15.6                   pypi_0    pypi
wheel                     0.33.6                   pypi_0    pypi
win_inet_pton             1.1.0                    py37_0
wincertstore              0.2                      py37_0
wrapt                     1.11.2           py37he774522_0
yaml                      0.1.7                hc54c509_2
zeromq                    4.3.1                h33f27b4_3
zipp                      0.5.2                      py_0
zlib                      1.2.11               h62dcd97_3
</code>```

Anyway, I don't understand why in the prompt HDF5 is version 1.10.4 and in the warning, version of HDF5 is 1.10.5

答:
I had the same problem as you. It came about because the tensorflow was installed by conda. And the error disappears when using channel anaconda.</p>

```<code>conda install -c anaconda tensorflow
</code>```

Body:
I'm trying to import some packages with spyder (OS x64), Anaconda and pyton 3.x
The error is pretty famous in the internet. The solution proposed is to match the version of the library 1.10.5 with the HDF5 (mine is 1.10.4)

The question is that I can't find HDF5 version 1.10.5
and, the other hand, cannot understand what I could downgrade.

At this link: https://anaconda.org/conda-forge/hdf5 seems exist version 1.10.5 but when I type in the prompt of anaconda conda install -c conda-forge hdf5
the version remain 1.10.4.

Here the warning:

Warning! ***HDF5 library version mismatched error***
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.10.4, library is 1.10.5
SUMMARY OF THE HDF5 CONFIGURATION
=================================

General Information:
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
HDF5 Version: 1.10.5
Configured on: 2019
Configured by: Visual Studio 15 2017 Win64
Host system: Windows.0.17763
Uname information: Windows
Byte sex: little‑endian
Installation point: C:/Program Files/HDF5

Compiling Options:
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
Build Mode:
Debugging Symbols:
Asserts:
Profiling:
Optimization Level:

Linking Options:
‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑‑
Libraries:
Statically Linked Executables: OFF
LDFLAGS: /machine:x64
H5_LDFLAGS:
AM_LDFLAGS:
Extra libraries:
Archiver:
Ranlib:

Languages:
‑‑‑‑‑‑‑‑‑‑
C: yes
C Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe 19.16.27027.1
CPPFLAGS:
H5_CPPFLAGS:
AM_CPPFLAGS:
CFLAGS: /DWIN32 /D_WINDOWS /W3
H5_CFLAGS:
AM_CFLAGS:
Shared C Library: YES
Static C Library: YES

Fortran: OFF
Fortran Compiler:
Fortran Flags:
H5 Fortran Flags:
AM Fortran Flags:
Shared Fortran Library: YES
Static Fortran Library: YES

C++: ON
C++ Compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe 19.16.27027.1
C++ Flags: /DWIN32 /D_WINDOWS /W3 /GR /EHsc
H5 C++ Flags:
AM C++ Flags:
Shared C++ Library: YES
Static C++ Library: YES

JAVA: OFF
JAVA Compiler:

Features:
‑‑‑‑‑‑‑‑‑
Parallel HDF5: OFF
Parallel Filtered Dataset Writes:
Large Parallel I/O:
High‑level library: ON
Threadsafety: OFF
Default API mapping: v110
With deprecated public symbols: ON
I/O filters (external): DEFLATE DECODE ENCODE
MPE:
Direct VFD:
dmalloc:
Packages w/ extra debug output:
API Tracing: OFF
Using memory checker: OFF
Memory allocation sanity checks: OFF
Function Stack Tracing: OFF
Strict File Format Checks: OFF
Optimization Instrumentation:
Bye...

Here all the packages installed:

# packages in environment at C:\Users\Megaport\Anaconda3\envs\venv:
#
# Name                    Version                   Build  Channel
_py-xgboost-mutex         2.0                       cpu_0
_tflow_select             2.3.0                       mkl
absl-py                   0.8.0                    pypi_0    pypi
alabaster                 0.7.12                   py37_0
asn1crypto                0.24.0                   py37_0
astor                     0.8.0                    pypi_0    pypi
astroid                   2.2.5                    py37_0
atomicwrites              1.3.0                    py37_1
attrs                     19.1.0                   py37_1
babel                     2.7.0                      py_0
backcall                  0.1.0                    py37_0
blas                      1.0                         mkl
bleach                    3.1.0                    py37_0
ca-certificates           2019.5.15                     1
certifi                   2019.6.16                py37_1
cffi                      1.12.3           py37h7a1dbc1_0
chardet                   3.0.4                 py37_1003
cloudpickle               1.2.1                      py_0
colorama                  0.4.1                    py37_0
cryptography              2.7              py37h7a1dbc1_0
cycler                    0.10.0                   py37_0
decorator                 4.4.0                    py37_1
defusedxml                0.6.0                      py_0
docutils                  0.15.2                   py37_0
entrypoints               0.3                      py37_0
fastcache                 1.1.0            py37he774522_0
freetype                  2.9.1                ha9979f8_1
gast                      0.2.2                    pypi_0    pypi
google-pasta              0.1.7                    pypi_0    pypi
grpcio                    1.23.0                   pypi_0    pypi
h5py                      2.10.0                   pypi_0    pypi
hdf5                      1.10.4               h7ebc959_0
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                 ha66f8fd_1
idna                      2.8                      py37_0
imagesize                 1.1.0                    py37_0
importlib_metadata        0.19                     py37_0
intel-openmp              2019.4                      245
ipykernel                 5.1.2            py37h39e3cac_0
ipython                   7.8.0            py37h39e3cac_0
ipython_genutils          0.2.0                    py37_0
isort                     4.3.21                   py37_0
jedi                      0.15.1                   py37_0
jinja2                    2.10.1                   py37_0
joblib                    0.13.2                   py37_0
jpeg                      9b                   hb83a4c4_2
jsonschema                3.0.2                    py37_0
jupyter_client            5.3.1                      py_0
jupyter_core              4.5.0                      py_0
keras                     2.2.4                         0
keras-applications        1.0.8                      py_0
keras-base                2.2.4                    py37_0
keras-preprocessing       1.1.0                      py_1
keyring                   18.0.0                   py37_0
kiwisolver                1.1.0            py37ha925a31_0
lazy-object-proxy         1.4.2            py37he774522_0
libmklml                  2019.0.5                      0
libpng                    1.6.37               h2a8f88b_0
libprotobuf               3.8.0                h7bd577a_0
libsodium                 1.0.16               h9d3ae62_0
libxgboost                0.90                          0
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  3.1.1                    py37_0
markupsafe                1.1.1            py37he774522_0
matplotlib                3.1.1            py37hc8f65d3_0
mccabe                    0.6.1                    py37_1
mistune                   0.8.4            py37he774522_0
mkl                       2019.4                      245
mkl-service               2.0.2            py37he774522_0
mkl_fft                   1.0.14           py37h14836fe_0
mkl_random                1.0.2            py37h343c172_0
more-itertools            7.2.0                    py37_0
mpmath                    1.1.0                    py37_0
msys2-conda-epoch         20160418                      1
nbconvert                 5.5.0                      py_0
nbformat                  4.4.0                    py37_0
numpy                     1.17.2                   pypi_0    pypi
numpy-base                1.16.4           py37hc3f5095_0
numpydoc                  0.9.1                      py_0
openssl                   1.1.1c               he774522_1
opt-einsum                3.0.1                    pypi_0    pypi
packaging                 19.1                     py37_0
pandas                    0.25.1           py37ha925a31_0
pandoc                    2.2.3.2                       0
pandocfilters             1.4.2                    py37_1
parso                     0.5.1                      py_0
pickleshare               0.7.5                    py37_0
pip                       19.2.2                   py37_0
pluggy                    0.12.0                     py_0
prompt_toolkit            2.0.9                    py37_0
protobuf                  3.9.1                    pypi_0    pypi
psutil                    5.6.3            py37he774522_0
py                        1.8.0                    py37_0
py-xgboost                0.90                     py37_0
py-xgboost-cpu            0.90                     py37_0
pycodestyle               2.5.0                    py37_0
pycparser                 2.19                     py37_0
pyflakes                  2.1.1                    py37_0
pygments                  2.4.2                      py_0
pylint                    2.3.1                    py37_0
pyopenssl                 19.0.0                   py37_0
pyparsing                 2.4.2                      py_0
pyqt                      5.9.2            py37h6538335_2
pyreadline                2.1                      py37_1
pyrsistent                0.14.11          py37he774522_0
pysocks                   1.7.0                    py37_0
pytest                    5.0.1                    py37_0
python                    3.7.4                h5263a28_0
python-dateutil           2.8.0                    py37_0
pytz                      2019.2                     py_0
pywin32                   223              py37hfa6e2cd_1
pyyaml                    5.1.2            py37he774522_0
pyzmq                     18.1.0           py37ha925a31_0
qt                        5.9.7            vc14h73c81de_0
qtawesome                 0.5.7                    py37_1
qtconsole                 4.5.4                      py_0
qtpy                      1.9.0                      py_0
requests                  2.22.0                   py37_0
rope                      0.14.0                     py_0
scikit-learn              0.21.2           py37h6288b17_0
scipy                     1.3.1            py37h29ff71c_0
setuptools                41.2.0                   pypi_0    pypi
sip                       4.19.8           py37h6538335_0
six                       1.12.0                   pypi_0    pypi
snowballstemmer           1.9.0                      py_0
sphinx                    2.1.2                      py_0
sphinxcontrib-applehelp   1.0.1                      py_0
sphinxcontrib-devhelp     1.0.1                      py_0
sphinxcontrib-htmlhelp    1.0.2                      py_0
sphinxcontrib-jsmath      1.0.1                      py_0
sphinxcontrib-qthelp      1.0.2                      py_0
sphinxcontrib-serializinghtml 1.1.3                      py_0
spyder                    3.3.6                    py37_0
spyder-kernels            0.5.1                    py37_0
sqlite                    3.29.0               he774522_0
sympy                     1.4                      py37_0
tb-nightly                1.15.0a20190806          pypi_0    pypi
tensorboard               1.14.0           py37he3c9ec2_0
tensorflow                1.14.0          mkl_py37h7908ca0_0
tensorflow-base           1.14.0          mkl_py37ha978198_0
tensorflow-estimator      1.14.0                     py_0
termcolor                 1.1.0                    pypi_0    pypi
testpath                  0.4.2                    py37_0
tornado                   6.0.3            py37he774522_0
traitlets                 4.3.2                    py37_0
urllib3                   1.24.2                   py37_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_0
wcwidth                   0.1.7                    py37_0
webencodings              0.5.1                    py37_1
werkzeug                  0.15.6                   pypi_0    pypi
wheel                     0.33.6                   pypi_0    pypi
win_inet_pton             1.1.0                    py37_0
wincertstore              0.2                      py37_0
wrapt                     1.11.2           py37he774522_0
yaml                      0.1.7                hc54c509_2
zeromq                    4.3.1                h33f27b4_3
zipp                      0.5.2                      py_0
zlib                      1.2.11               h62dcd97_3

Anyway, I don't understand why in the prompt HDF5 is version 1.10.4 and in the warning, version of HDF5 is 1.10.5

Body:
I had the same problem as you. It came about because the tensorflow was installed by conda. And the error disappears when using channel anaconda.

conda install -c anaconda tensorflow