问:
Spring boot logback issue when intending to run executable fat jar file
I am new to spring boot. I have developed an app and it runs in Intellij IDE without any problem. I want to deploy an executable jar and run it through command window. To this end, I respectively applied the following commands in the related folder:

```<code>mvn clear

mvn install
</code>```

Please note that in my app I use two external jar files. One of them is ojdbc.jar for Oracle db connections and the other contains a Scala code using Apache Spark(cosinelsh.jar). So the command above should create a fat jar file. Indeed, this process went smoothly. However when intending to run the file (java -jar target/mlee.jar), the error below is thrown:

```<code>SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/n12017/AppData/Local/Temp/mlee-exe-jar.jar-spring-boot-libs-65763e64-4a74-4d8f-b23a-0a20f028113c/cosinelsh-1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/n12017/IdeaProjects/LSH_USER/target/mlee-exe-jar.jar!/BOOT-INF/lib/logback-classic-1.1.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/C:/Users/n12017/AppData/Local/Temp/mlee-exe-jar.jar-spring-boot-libs-65763e64-4a74-4d8f-b23a-0a20f028113c/cosinelsh-1.0.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
        at org.springframework.util.Assert.isInstanceOf(Assert.java:346)
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:273)
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:97)
        at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:230)
        at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:209)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
        at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:68)
        at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
        at softuniBlog.DemoApplication.main(DemoApplication.java:12)
        ... 8 more
</code>```

From similar questions in stackoverflow (Favoring LogBack over Log4j in spring-boot/ security or Disable Logback in SpringBoot), I have tried similar approaches but always failed.

Here is the dependency tree:

```<code>--- maven-dependency-plugin:2.10:tree (default-cli) @ demo ---
[INFO] Blog:demo:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.11:compile
[INFO] |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.11:compile
[INFO] |  \- org.springframework:spring-jdbc:jar:4.3.6.RELEASE:compile
[INFO] |     +- org.springframework:spring-beans:jar:4.3.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-tx:jar:4.3.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.3.6.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-config:jar:4.2.1.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-core:jar:4.2.1.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-web:jar:4.2.1.RELEASE:compile
[INFO] |     +- org.springframework:spring-expression:jar:4.3.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-web:jar:4.3.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-web:jar:1.5.1.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.1.RELEASE:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile
[INFO] |  |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile
[INFO] |  |  +- org.hibernate:hibernate-validator:jar:5.3.4.Final:compile
[INFO] |  |  |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  |  |  \- com.fasterxml:classmate:jar:1.3.3:compile
[INFO] |  |  \- org.springframework:spring-webmvc:jar:4.3.6.RELEASE:compile
[INFO] |  +- org.thymeleaf:thymeleaf-spring4:jar:2.1.5.RELEASE:compile
[INFO] |  \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
[INFO] |     \- org.codehaus.groovy:groovy:jar:2.4.7:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.1.RELEASE:compile
[INFO] |  |  +- ch.qos.logback:logback-classic:jar:1.1.9:compile
[INFO] |  |  |  \- ch.qos.logback:logback-core:jar:1.1.9:compile
[INFO] |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile
[INFO] |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.22:compile
[INFO] |  +- org.springframework:spring-core:jar:4.3.6.RELEASE:compile
[INFO] |  \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:1.5.1.RELEASE:runtime
[INFO] +- mysql:mysql-connector-java:jar:5.1.40:runtime
[INFO] +- com.microsoft.sqlserver:mssql-jdbc:jar:6.1.0.jre7:runtime
[INFO] |  \- com.microsoft.azure:azure-keyvault:jar:0.9.3:runtime
[INFO] |     +- com.microsoft.azure:azure-core:jar:0.9.3:runtime
[INFO] |     |  +- commons-codec:commons-codec:jar:1.10:runtime
[INFO] |     |  +- commons-lang:commons-lang:jar:2.6:runtime
[INFO] |     |  +- com.sun.jersey:jersey-client:jar:1.13:runtime
[INFO] |     |  |  \- com.sun.jersey:jersey-core:jar:1.13:runtime
[INFO] |     |  \- com.sun.jersey:jersey-json:jar:1.13:runtime
[INFO] |     |     +- org.codehaus.jettison:jettison:jar:1.1:runtime
[INFO] |     |     |  \- stax:stax-api:jar:1.0.1:runtime
[INFO] |     |     +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:runtime
[INFO] |     |     |  \- javax.xml.bind:jaxb-api:jar:2.2.2:runtime
[INFO] |     |     |     \- javax.xml.stream:stax-api:jar:1.0-2:runtime
[INFO] |     |     +- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:runtime
[INFO] |     |     +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:runtime
[INFO] |     |     +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:runtime
[INFO] |     |     \- org.codehaus.jackson:jackson-xc:jar:1.9.2:runtime
[INFO] |     +- org.apache.httpcomponents:httpclient:jar:4.5.2:runtime
[INFO] |     |  \- org.apache.httpcomponents:httpcore:jar:4.4.6:runtime
[INFO] |     +- javax.inject:javax.inject:jar:1:runtime
[INFO] |     \- com.microsoft.azure:adal4j:jar:1.0.0:runtime
[INFO] |        +- com.nimbusds:oauth2-oidc-sdk:jar:4.5:runtime
[INFO] |        |  +- net.jcip:jcip-annotations:jar:1.0:runtime
[INFO] |        |  +- org.apache.commons:commons-lang3:jar:3.3.1:runtime
[INFO] |        |  +- com.nimbusds:lang-tag:jar:1.4:runtime
[INFO] |        |  \- com.nimbusds:nimbus-jose-jwt:jar:3.1.2:runtime
[INFO] |        |     \- org.bouncycastle:bcprov-jdk15on:jar:1.51:runtime
[INFO] |        \- com.google.code.gson:gson:jar:2.8.0:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.1.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:1.5.1.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.1.RELEASE:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.2.1:runtime
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.1:runtime
[INFO] |  |        \- org.ow2.asm:asm:jar:5.0.3:runtime
[INFO] |  +- junit:junit:jar:4.12:test
[INFO] |  +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] |  +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.1:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.4.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  \- org.springframework:spring-test:jar:4.3.6.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.1.RELEASE:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.0.11.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:5.0.11.Final:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:1.11.0.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:1.13.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-orm:jar:4.3.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-aspects:jar:4.3.6.RELEASE:compile
[INFO] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity4:jar:2.1.2.RELEASE:compile
[INFO] |  +- org.thymeleaf:thymeleaf:jar:2.1.5.RELEASE:compile
[INFO] |  |  +- ognl:ognl:jar:3.0.8:compile
[INFO] |  |  \- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] +- com.oracle:ojdbc6:jar:11.2.0.4:compile
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.3.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-context-support:jar:4.3.6.RELEASE:compile
[INFO] |  \- com.sun.mail:javax.mail:jar:1.5.6:compile
[INFO] +- javax.mail:mail:jar:1.4.1:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.scala-lang:scala-library:jar:2.10.0:compile
[INFO] +- cosine-lsh:cosinelsh:jar:1.0:compile
[INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.4.4:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO]    \- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile
[INFO]    \- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile
</code>```

And pom.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>Blog</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Blog Project from the Software Technologies Course</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity4</artifactId>
            <version>2.1.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.4</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
            <!--<version>1.4.3.RELEASE</version>-->
        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.1</version>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.10.0</version>
        </dependency>

        <dependency>
            <groupId>cosine-lsh</groupId>
            <artifactId>cosinelsh</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.4.4</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>mlee-exe-jar</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <requiresUnpack>
                        <dependency>
                            <groupId>cosine-lsh</groupId>
                            <artifactId>cosinelsh</artifactId>
                            <version>1.0</version>
                        </dependency>
                    </requiresUnpack>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
</code>```

I got stuck! Can somebody help?

Thanks in advance!

EDIT

I could get rid of binding logging as James Fry suggested as below:

```<code><dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>
</code>```

However, when jar file is run through command window it starts and ends after a few second:

```<code>log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.1.RELEASE)
</code>```

EDIT 2

```<code>org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.6.RELEASE.jar!/:4.3.6.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at softuniBlog.DemoApplication.main(DemoApplication.java:12) [classes!/:0.0.1-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_121]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:117) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:84) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:537) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        ... 16 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [StandardServer[-1]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:343) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        ... 21 common frames omitted
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.SAXParserFactory cannot be created
        at javax.xml.parsers.FactoryFinder.findServiceProvider(Unknown Source) ~[na:1.8.0_121]
        at javax.xml.parsers.FactoryFinder.find(Unknown Source) ~[na:1.8.0_121]
        at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source) ~[na:1.8.0_121]
        at org.apache.tomcat.util.digester.Digester.getFactory(Digester.java:432) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.digester.Digester.getParser(Digester.java:617) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.digester.Digester.getXMLReader(Digester.java:809) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1477) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.execute(MbeansDescriptorsDigesterSource.java:170) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.loadDescriptors(MbeansDescriptorsDigesterSource.java:149) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.load(Registry.java:590) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java:669) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.findDescriptor(Registry.java:703) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.findManagedBean(Registry.java:479) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.registerComponent(Registry.java:622) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.util.LifecycleMBeanBase.register(LifecycleMBeanBase.java:161) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.util.LifecycleMBeanBase.initInternal(LifecycleMBeanBase.java:61) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:829) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        ... 24 common frames omitted
Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.SAXParserFactory cannot be created
        ... 42 common frames omitted
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.SAXParserFactory: Error reading configuration file
        at java.util.ServiceLoader.fail(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader.parse(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader.access$200(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader$LazyIterator.hasNextService(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader$LazyIterator.hasNext(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader$1.hasNext(Unknown Source) ~[na:1.8.0_121]
        at javax.xml.parsers.FactoryFinder$1.run(Unknown Source) ~[na:1.8.0_121]
        at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_121]
        ... 42 common frames omitted
Caused by: java.io.FileNotFoundException: JAR entry META-INF/services/javax.xml.parsers.SAXParserFactory not found in C:\Users\n12017\AppData\Local\Temp\mlee-exe-jar.jar-spring-boot-libs-7a6ac511-970e-415f-bccb-432a1d0c7cee\cosinelsh-1.0.jar
        at org.springframework.boot.loader.jar.JarURLConnection.throwFileNotFound(JarURLConnection.java:185) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.jar.JarURLConnection.connect(JarURLConnection.java:104) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.jar.JarURLConnection.getInputStream(JarURLConnection.java:169) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at java.net.URL.openStream(Unknown Source) ~[na:1.8.0_121]
        ... 49 common frames omitted
</code>```

答:
You should exclude the other implementation from the problematic import - in this case your cosinelsh jar contains SLF4J logger bindings, as well as the logback-classic-1.1.9.jar that's brought in through Spring Boot.

I believe the correct fix is to build the cosinelsh jar without these dependencies, if you are able to (eg by setting the scope to "provided" or similar). If that is not possible, you may be able to removing the spring boot supplied libraries from the spring-boot-starter-logging dependency (brought in through spring-boot-starter), eg:

```<code>        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
</code>```

Body:
I am new to spring boot. I have developed an app and it runs in Intellij IDE without any problem. I want to deploy an executable jar and run it through command window. To this end, I respectively applied the following commands in the related folder:

mvn clear

mvn install

Please note that in my app I use two external jar files. One of them is ojdbc.jar for Oracle db connections and the other contains a Scala code using Apache Spark(cosinelsh.jar). So the command above should create a fat jar file. Indeed, this process went smoothly. However when intending to run the file (java -jar target/mlee.jar), the error below is thrown:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/n12017/AppData/Local/Temp/mlee-exe-jar.jar-spring-boot-libs-65763e64-4a74-4d8f-b23a-0a20f028113c/cosinelsh-1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/n12017/IdeaProjects/LSH_USER/target/mlee-exe-jar.jar!/BOOT-INF/lib/logback-classic-1.1.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/C:/Users/n12017/AppData/Local/Temp/mlee-exe-jar.jar-spring-boot-libs-65763e64-4a74-4d8f-b23a-0a20f028113c/cosinelsh-1.0.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml Object of class [org.slf4j.impl.Log4jLoggerFactory] must be an instance of class ch.qos.logback.classic.LoggerContext
        at org.springframework.util.Assert.isInstanceOf(Assert.java:346)
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:273)
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:97)
        at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:230)
        at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:209)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
        at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:68)
        at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
        at softuniBlog.DemoApplication.main(DemoApplication.java:12)
        ... 8 more

From similar questions in stackoverflow (Favoring LogBack over Log4j in spring-boot/ security or Disable Logback in SpringBoot), I have tried similar approaches but always failed.

Here is the dependency tree:

--- maven-dependency-plugin:2.10:tree (default-cli) @ demo ---
[INFO] Blog:demo:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.11:compile
[INFO] |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.11:compile
[INFO] |  \- org.springframework:spring-jdbc:jar:4.3.6.RELEASE:compile
[INFO] |     +- org.springframework:spring-beans:jar:4.3.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-tx:jar:4.3.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:4.3.6.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-config:jar:4.2.1.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-core:jar:4.2.1.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-web:jar:4.2.1.RELEASE:compile
[INFO] |     +- org.springframework:spring-expression:jar:4.3.6.RELEASE:compile
[INFO] |     \- org.springframework:spring-web:jar:4.3.6.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-web:jar:1.5.1.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.1.RELEASE:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.11:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.11:compile
[INFO] |  |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.11:compile
[INFO] |  |  +- org.hibernate:hibernate-validator:jar:5.3.4.Final:compile
[INFO] |  |  |  +- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  |  |  \- com.fasterxml:classmate:jar:1.3.3:compile
[INFO] |  |  \- org.springframework:spring-webmvc:jar:4.3.6.RELEASE:compile
[INFO] |  +- org.thymeleaf:thymeleaf-spring4:jar:2.1.5.RELEASE:compile
[INFO] |  \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
[INFO] |     \- org.codehaus.groovy:groovy:jar:2.4.7:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.1.RELEASE:compile
[INFO] |  |  +- ch.qos.logback:logback-classic:jar:1.1.9:compile
[INFO] |  |  |  \- ch.qos.logback:logback-core:jar:1.1.9:compile
[INFO] |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.22:compile
[INFO] |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.22:compile
[INFO] |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.22:compile
[INFO] |  +- org.springframework:spring-core:jar:4.3.6.RELEASE:compile
[INFO] |  \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] +- org.springframework.boot:spring-boot-devtools:jar:1.5.1.RELEASE:runtime
[INFO] +- mysql:mysql-connector-java:jar:5.1.40:runtime
[INFO] +- com.microsoft.sqlserver:mssql-jdbc:jar:6.1.0.jre7:runtime
[INFO] |  \- com.microsoft.azure:azure-keyvault:jar:0.9.3:runtime
[INFO] |     +- com.microsoft.azure:azure-core:jar:0.9.3:runtime
[INFO] |     |  +- commons-codec:commons-codec:jar:1.10:runtime
[INFO] |     |  +- commons-lang:commons-lang:jar:2.6:runtime
[INFO] |     |  +- com.sun.jersey:jersey-client:jar:1.13:runtime
[INFO] |     |  |  \- com.sun.jersey:jersey-core:jar:1.13:runtime
[INFO] |     |  \- com.sun.jersey:jersey-json:jar:1.13:runtime
[INFO] |     |     +- org.codehaus.jettison:jettison:jar:1.1:runtime
[INFO] |     |     |  \- stax:stax-api:jar:1.0.1:runtime
[INFO] |     |     +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:runtime
[INFO] |     |     |  \- javax.xml.bind:jaxb-api:jar:2.2.2:runtime
[INFO] |     |     |     \- javax.xml.stream:stax-api:jar:1.0-2:runtime
[INFO] |     |     +- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:runtime
[INFO] |     |     +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:runtime
[INFO] |     |     +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:runtime
[INFO] |     |     \- org.codehaus.jackson:jackson-xc:jar:1.9.2:runtime
[INFO] |     +- org.apache.httpcomponents:httpclient:jar:4.5.2:runtime
[INFO] |     |  \- org.apache.httpcomponents:httpcore:jar:4.4.6:runtime
[INFO] |     +- javax.inject:javax.inject:jar:1:runtime
[INFO] |     \- com.microsoft.azure:adal4j:jar:1.0.0:runtime
[INFO] |        +- com.nimbusds:oauth2-oidc-sdk:jar:4.5:runtime
[INFO] |        |  +- net.jcip:jcip-annotations:jar:1.0:runtime
[INFO] |        |  +- org.apache.commons:commons-lang3:jar:3.3.1:runtime
[INFO] |        |  +- com.nimbusds:lang-tag:jar:1.4:runtime
[INFO] |        |  \- com.nimbusds:nimbus-jose-jwt:jar:3.1.2:runtime
[INFO] |        |     \- org.bouncycastle:bcprov-jdk15on:jar:1.51:runtime
[INFO] |        \- com.google.code.gson:gson:jar:2.8.0:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.1.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:1.5.1.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.1.RELEASE:test
[INFO] |  +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] |  |  \- net.minidev:json-smart:jar:2.2.1:runtime
[INFO] |  |     \- net.minidev:accessors-smart:jar:1.1:runtime
[INFO] |  |        \- org.ow2.asm:asm:jar:5.0.3:runtime
[INFO] |  +- junit:junit:jar:4.12:test
[INFO] |  +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] |  +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.1:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.4.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  \- org.springframework:spring-test:jar:4.3.6.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.1.RELEASE:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.0.11.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  |  +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:5.0.11.Final:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:1.11.0.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:1.13.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-orm:jar:4.3.6.RELEASE:compile
[INFO] |  \- org.springframework:spring-aspects:jar:4.3.6.RELEASE:compile
[INFO] +- org.thymeleaf.extras:thymeleaf-extras-springsecurity4:jar:2.1.2.RELEASE:compile
[INFO] |  +- org.thymeleaf:thymeleaf:jar:2.1.5.RELEASE:compile
[INFO] |  |  +- ognl:ognl:jar:3.0.8:compile
[INFO] |  |  \- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.22:compile
[INFO] +- com.oracle:ojdbc6:jar:11.2.0.4:compile
[INFO] +- org.springframework.boot:spring-boot-starter-mail:jar:1.5.1.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.3.6.RELEASE:compile
[INFO] |  +- org.springframework:spring-context-support:jar:4.3.6.RELEASE:compile
[INFO] |  \- com.sun.mail:javax.mail:jar:1.5.6:compile
[INFO] +- javax.mail:mail:jar:1.4.1:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.scala-lang:scala-library:jar:2.10.0:compile
[INFO] +- cosine-lsh:cosinelsh:jar:1.0:compile
[INFO] \- com.fasterxml.jackson.core:jackson-databind:jar:2.4.4:compile
[INFO]    +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
[INFO]    \- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile
[INFO]    \- com.fasterxml.jackson.core:jackson-core:jar:2.8.6:compile

And pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>Blog</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>demo</name>
    <description>Blog Project from the Software Technologies Course</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.1.RELEASE</version>
        <relativePath/>
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity4</artifactId>
            <version>2.1.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.4</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>

        </dependency>

        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.1</version>
        </dependency>

        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>2.10.0</version>
        </dependency>

        <dependency>
            <groupId>cosine-lsh</groupId>
            <artifactId>cosinelsh</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.4.4</version>
        </dependency>

    </dependencies>

    <build>
        <finalName>mlee-exe-jar</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <requiresUnpack>
                        <dependency>
                            <groupId>cosine-lsh</groupId>
                            <artifactId>cosinelsh</artifactId>
                            <version>1.0</version>
                        </dependency>
                    </requiresUnpack>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

I got stuck! Can somebody help?

Thanks in advance!

EDIT

I could get rid of binding logging as James Fry suggested as below:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
    </exclusions>
</dependency>

However, when jar file is run through command window it starts and ends after a few second:

log4j:WARN No appenders could be found for logger (org.springframework.web.context.support.StandardServletEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.1.RELEASE)

EDIT 2

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.6.RELEASE.jar!/:4.3.6.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at softuniBlog.DemoApplication.main(DemoApplication.java:12) [classes!/:0.0.1-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_121]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_121]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [mlee-exe-jar.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:117) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:84) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:537) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:179) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        ... 16 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to initialize component [StandardServer[-1]]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:112) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.startup.Tomcat.start(Tomcat.java:343) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:98) ~[spring-boot-1.5.1.RELEASE.jar!/:1.5.1.RELEASE]
        ... 21 common frames omitted
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.SAXParserFactory cannot be created
        at javax.xml.parsers.FactoryFinder.findServiceProvider(Unknown Source) ~[na:1.8.0_121]
        at javax.xml.parsers.FactoryFinder.find(Unknown Source) ~[na:1.8.0_121]
        at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source) ~[na:1.8.0_121]
        at org.apache.tomcat.util.digester.Digester.getFactory(Digester.java:432) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.digester.Digester.getParser(Digester.java:617) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.digester.Digester.getXMLReader(Digester.java:809) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1477) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.execute(MbeansDescriptorsDigesterSource.java:170) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.loadDescriptors(MbeansDescriptorsDigesterSource.java:149) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.load(Registry.java:590) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java:669) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.findDescriptor(Registry.java:703) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.findManagedBean(Registry.java:479) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.tomcat.util.modeler.Registry.registerComponent(Registry.java:622) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.util.LifecycleMBeanBase.register(LifecycleMBeanBase.java:161) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.util.LifecycleMBeanBase.initInternal(LifecycleMBeanBase.java:61) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:829) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:107) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
        ... 24 common frames omitted
Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.SAXParserFactory cannot be created
        ... 42 common frames omitted
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.SAXParserFactory: Error reading configuration file
        at java.util.ServiceLoader.fail(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader.parse(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader.access$200(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader$LazyIterator.hasNextService(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader$LazyIterator.hasNext(Unknown Source) ~[na:1.8.0_121]
        at java.util.ServiceLoader$1.hasNext(Unknown Source) ~[na:1.8.0_121]
        at javax.xml.parsers.FactoryFinder$1.run(Unknown Source) ~[na:1.8.0_121]
        at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_121]
        ... 42 common frames omitted
Caused by: java.io.FileNotFoundException: JAR entry META-INF/services/javax.xml.parsers.SAXParserFactory not found in C:\Users\n12017\AppData\Local\Temp\mlee-exe-jar.jar-spring-boot-libs-7a6ac511-970e-415f-bccb-432a1d0c7cee\cosinelsh-1.0.jar
        at org.springframework.boot.loader.jar.JarURLConnection.throwFileNotFound(JarURLConnection.java:185) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.jar.JarURLConnection.connect(JarURLConnection.java:104) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.jar.JarURLConnection.getInputStream(JarURLConnection.java:169) ~[mlee-exe-jar.jar:0.0.1-SNAPSHOT]
        at java.net.URL.openStream(Unknown Source) ~[na:1.8.0_121]
        ... 49 common frames omitted

Body:
You should exclude the other implementation from the problematic import - in this case your cosinelsh jar contains SLF4J logger bindings, as well as the logback-classic-1.1.9.jar that's brought in through Spring Boot.

I believe the correct fix is to build the cosinelsh jar without these dependencies, if you are able to (eg by setting the scope to "provided" or similar). If that is not possible, you may be able to removing the spring boot supplied libraries from the spring-boot-starter-logging dependency (brought in through spring-boot-starter), eg:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


来源: stackexchange

问:
C++ - undefined reference to 'Class::variable'
I keep getting error: undefined reference to 'Company::budget'.
My method is set so as to take the value of company's (any created) budget and subtract Employees' salary from it. I keep getting this problem. Tried both pointers and let's say "normal calling". Ok, there's the code snippet: (rest of it works)

company.h

```<code>#include <iostream>
#include <cstdlib>
#include <list>
#include <vector>
#include "employee.h"
using namespace std;

class Company
{
public:
    Company* comp;
    void  hire(Employee& emp, float putSalary);
    void  fire(Employee& emp);
    void  endOfMonth(Company& comp);
    Company(float);
 //   static float moneyamount;
private:
    static float budget;
    vector <Employee>* Employees;
};
</code>```

company.cpp

```<code>void Company::endOfMonth(Company& comp)
{
    for (iterat=0; iterat < Employees->size() ; iterat++)
    {

        cout << (*Employees)[iterat].fullName << endl;
        cout << (*Employees)[iterat].getSalary() << endl;
        comp.budget = comp.budget - (*Employees)[iterat].getSalary();
    }
}
</code>```

答:
Static class members variables are static over all instances of a class. So if you have two instances of one class, they share the static variable. Also, these variables are also valid even when there is no instance of the class. So, static member functions may use static member variables. That is the reason why they must defined somewhere outside the class in the object file.

You define it and reserve the necessary space for it in memory at the top level of you .cpp file:

```<code>float Company::budget;
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I keep getting error: undefined reference to 'Company::budget'.
My method is set so as to take the value of company's (any created) budget and subtract Employees' salary from it. I keep getting this problem. Tried both pointers and let's say "normal calling". Ok, there's the code snippet: (rest of it works)

company.h

#include <iostream>
#include <cstdlib>
#include <list>
#include <vector>
#include "employee.h"
using namespace std;

class Company
{
public:
    Company* comp;
    void  hire(Employee& emp, float putSalary);
    void  fire(Employee& emp);
    void  endOfMonth(Company& comp);
    Company(float);
 //   static float moneyamount;
private:
    static float budget;
    vector <Employee>* Employees;
};

company.cpp

void Company::endOfMonth(Company& comp)
{
    for (iterat=0; iterat < Employees->size() ; iterat++)
    {

        cout << (*Employees)[iterat].fullName << endl;
        cout << (*Employees)[iterat].getSalary() << endl;
        comp.budget = comp.budget - (*Employees)[iterat].getSalary();
    }
}

Body:
Static class members variables are static over all instances of a class. So if you have two instances of one class, they share the static variable. Also, these variables are also valid even when there is no instance of the class. So, static member functions may use static member variables. That is the reason why they must defined somewhere outside the class in the object file.

You define it and reserve the necessary space for it in memory at the top level of you .cpp file:

float Company::budget;


问:
Java File Input/Output. Letter Occurances in a given File
my problem is:

Write a program that prompts the user to enter a file name and display the occurrences of each letter in the file. Must use exceptions. Letters are not case-sensitive.

Here is a sample run:

```<code>Enter the File name: example.txt

The Occurrence of A's is 11
The Occurrence of B's is 2
....
The Occurrence of Y's is 3
The Occurrence of Z's is 2.
</code>```

My code was made thinking I had to be case sensitive which I do not have to be. So how do I change my code to include all letters and not just Capital letter. I do not have much time to solve it myself which is why i posted it here:

```<code>  import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;

  public class LetterOccurance
 {
  public static void main(String[] args) {

    System.out.print("Enter file name: ");
    File file = new File(new Scanner(System.in).next());

    if (!file.exists())
    {
        System.out.println(file + " doesn't exist");
        System.exit(1);
    }
    String buffer = "";
    int[] letterCount = new int[26];
    try (Scanner input = new Scanner(file))
    {

        while (input.hasNext())
        {
            buffer = input.nextLine();
            for (char ch : buffer.toCharArray())
            {
                ch = Character.toUpperCase(ch);
                if (isLetter(ch))
                {
                    letterCount[ch - 'A']++;
                }
            }

        }
    }
    catch (FileNotFoundException ex)
    {
        ex.printStackTrace();
    }

    for (int i = 0; i < letterCount.length; i++)
    {
        System.out.println((char)(i + 'A') + " occurrence = " + letterCount[i]);
    }

}

private static boolean isLetter(char ch)
{

    return (ch >= 'A' && ch <= 'Z');
}
}
</code>```

答: You can either choose to use upper or lowercase. Whichever you use, you do the same for the text your're looking at and the text you'r comparing too. So you would do toUpperCase() (or lower) on the string from the file and then look for upper (or lowercase) letters</p>

Body:
my problem is:

Write a program that prompts the user to enter a file name and display the occurrences of each letter in the file. Must use exceptions. Letters are not case-sensitive.

Here is a sample run:

Enter the File name: example.txt

The Occurrence of A's is 11
The Occurrence of B's is 2
....
The Occurrence of Y's is 3
The Occurrence of Z's is 2.

My code was made thinking I had to be case sensitive which I do not have to be. So how do I change my code to include all letters and not just Capital letter. I do not have much time to solve it myself which is why i posted it here:

  import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.Scanner;

  public class LetterOccurance
 {
  public static void main(String[] args) {

    System.out.print("Enter file name: ");
    File file = new File(new Scanner(System.in).next());

    if (!file.exists())
    {
        System.out.println(file + " doesn't exist");
        System.exit(1);
    }
    String buffer = "";
    int[] letterCount = new int[26];
    try (Scanner input = new Scanner(file))
    {

        while (input.hasNext())
        {
            buffer = input.nextLine();
            for (char ch : buffer.toCharArray())
            {
                ch = Character.toUpperCase(ch);
                if (isLetter(ch))
                {
                    letterCount[ch - 'A']++;
                }
            }

        }
    }
    catch (FileNotFoundException ex)
    {
        ex.printStackTrace();
    }

    for (int i = 0; i < letterCount.length; i++)
    {
        System.out.println((char)(i + 'A') + " occurrence = " + letterCount[i]);
    }

}

private static boolean isLetter(char ch)
{

    return (ch >= 'A' && ch <= 'Z');
}
}


问:
Using an array based formula in conditional formatting
What I am trying to do with excel is a bit unorthodox, but I need a method of cleaning the data people import in to TechExcel's DevTrack. DevTrack creates values for fields if what you attempt to import is not 100% accurate to what exists already in the project, leading to duplicate values with slightly different formatting.

What I have come to is having a "validator" excel sheet; people copy/paste what they want to import, and anything that doesn't match a data validation table is highlighted.

Data validation itself does not work because copy/paste overwrites it and it is a waste of time to enter data manually.

I have managed to get conditional formatting working partially using this formula:
=ISERROR(MATCH(C5,D:D,0))

However it is not case sensitive. I need case sensitivity.

So I managed to create another formula which shows true if there is no match, however exact requires it to be an array formula which doesn't seem to work with conditional formatting.

So this works if it is entered in to a cell with ctrl+shift+enter, but doesn't work as a conditional rule.
{=ISERROR(MATCH(TRUE,EXACT(C5,D:D),0))}

Here is a simplified version of what I'm looking at for testing. That formula is true when there is no case match, but I can't enter it in conditional formatting with ctrl+shift+enter. If this worked as I want it to, the lower case "melon" would highlight red.

Is there a way to get this working, or is there an alternative method to do this?

If it matters, I'm using the latest version of excel in office 365.

答:
Use a function that produces array processing without CSE. Examples are SUMPRODUCT or AGGREGATE (among others).

```<code>'to show TRUE for case-sensitive matches
=SIGN(AGGREGATE(15, 6, ROW($D$5:$D$9999)/EXACT($C5, $D$5:$D999), 1))
'to show TRUE on no case-sensitive match
=ISERROR(AGGREGATE(15, 6, ROW($D$5:$D$9999)/EXACT($C5, $D$5:$D999), 1))
</code>```

The SIGN wrapper is unnecessary but for me it is a visual reminder that I'm looking for a boolean.

You cannot use dynamic ranges like D5:INDEX(D:D, MATCH("zzz", D:D)) in a CFR and you do not want to use full column references in AGGREGATE (or SUMPRODUCT) so I opted for $D$5:$D$9999.

Body:
Use a function that produces array processing without CSE. Examples are SUMPRODUCT or AGGREGATE (among others).

'to show TRUE for case-sensitive matches
=SIGN(AGGREGATE(15, 6, ROW($D$5:$D$9999)/EXACT($C5, $D$5:$D999), 1))
'to show TRUE on no case-sensitive match
=ISERROR(AGGREGATE(15, 6, ROW($D$5:$D$9999)/EXACT($C5, $D$5:$D999), 1))

The SIGN wrapper is unnecessary but for me it is a visual reminder that I'm looking for a boolean.

You cannot use dynamic ranges like D5:INDEX(D:D, MATCH("zzz", D:D)) in a CFR and you do not want to use full column references in AGGREGATE (or SUMPRODUCT) so I opted for $D$5:$D$9999.


问:
How configure job execution for sudo users with NOPASSWD option?
I try run command from another user remotely from rundeck jobs.
Rundeck provide sudo login\passwod mechanism for escalate privilege.
On my remote server in sudoers file NOPASSWD option. How i can configure rundeck jobs in this case?

my node configurations:

```<code><project>
        <node name="testServer"
                type="Node"
                description="testNode"
                hostname="IP_ADDRESS"
                username="${option.Login}"
                ssh-authentication="password"
                sudo-command-enabled="true"
                ssh-password-option="option.Password"
                />

</project>
</code>```

Example command in job for become another user:

```<code>sudo /bin/su suuser -
</code>```

Error's after trying executions:

```<code>Remote command failed with exit status -1
08:57:13            Sudo execution password response failed: Failed waiting for input prompt: Expected input was not seen in 5000 milliseconds
08:57:13            Failed: NonZeroResultCode: Remote command failed with exit status -1
</code>```

答:
I added the following three attributes to my node and it appears to work:

sudo-command-enabled="true"

sudo-prompt-pattern=""

sudo-command-pattern="^sudo.*"

Body:
I try run command from another user remotely from rundeck jobs.
Rundeck provide sudo login\passwod mechanism for escalate privilege.
On my remote server in sudoers file NOPASSWD option. How i can configure rundeck jobs in this case?

my node configurations:

<project>
        <node name="testServer"
                type="Node"
                description="testNode"
                hostname="IP_ADDRESS"
                username="${option.Login}"
                ssh-authentication="password"
                sudo-command-enabled="true"
                ssh-password-option="option.Password"
                />

</project>

Example command in job for become another user:

sudo /bin/su suuser -

Error's after trying executions:

Remote command failed with exit status -1
08:57:13            Sudo execution password response failed: Failed waiting for input prompt: Expected input was not seen in 5000 milliseconds
08:57:13            Failed: NonZeroResultCode: Remote command failed with exit status -1


问:
Universal link with branch.io doesnt work with iPhone when it works with iPad
My App is in production now, and within my app I create a Universal link using branch.io and share it to other users using for example iMessage. Example link below I got from my friend is below:

I have the app from App Store installed on both devices: iPad and iPhone. Now the above link I tap on iPad and everything is fine. My App is opened I can catch the link:)

But when I tap it on iPhone the result is following:

Why? Shouldnt it works the same way on both: iPad and iPhone? I do not know what is wrong here... Any questions? I can change and add additional info here to help the solve the problem.

This is how I defined it in dashboard of branch.io:

答:
You are encountering a new behavior introduced with iOS 10.3. The pop-up you are seeing will open the app now only if the user responds to the pop-up alert affirmatively. You must have not yet updated your iPad.

There is an unexpected issue with this new behavior beyond the obvious:
if the user taps "Cancel" on the pop-up alert, he or she will be stuck on a blank page in Safari. To improve this experience I recommend setting the $ios_passive_deepview parameter to the key of a Deepview of your choice (branch_default is the default, I believe).


问:
Gsoap databinding how to remove namespace definitions in my xml
So im very new to gsoap and im fumbling around trying to my resulting xml code to match the xml that I need.  For some reason all of my xml looks like this:

```<code><ns1:system>linux</ns1:system>
</code>```

but the problem is I need it to look like this:

```<code><system>linux</system>
</code>```

Is there some sort of option/flag that I can turn on / off to remove the ns1 or do I have to do something completely different?  Like I said I am very new to gsoap, so this could be something really simple that im missing or it could not even be a namespace problem, I have no idea.  If you need any more information I'll be happy to provide it.

Thanks for any help,
Josh

答: you need to turn off default element qualification. It's been too long for me to remember the gsoap recipe, but if you search for those terms you'll find it.</p>

ContentLicense: CC BY-SA 2.5

Body:
So im very new to gsoap and im fumbling around trying to my resulting xml code to match the xml that I need.  For some reason all of my xml looks like this:

<ns1:system>linux</ns1:system>

but the problem is I need it to look like this:

<system>linux</system>

Is there some sort of option/flag that I can turn on / off to remove the ns1 or do I have to do something completely different?  Like I said I am very new to gsoap, so this could be something really simple that im missing or it could not even be a namespace problem, I have no idea.  If you need any more information I'll be happy to provide it.

Thanks for any help,
Josh


问:
Set random Password and Salt
I want to create random password and salt.

Now I have a function based who Encrypt password like:

```<code>public string EncryptPassword(string password, string salt)
{
        using (var sha256 = SHA256.Create())
        {
             var saltedPassword = string.Format("{0}{1}", salt, password);
             byte[] saltedPasswordAsBytes = Encoding.UTF8.GetBytes(saltedPassword);
             return Convert.ToBase64String(sha256.ComputeHash(saltedPasswordAsBytes));
        }
}
</code>```

So I want to do same encode password and salt but with random values, and before encode it I want to know what password is. How can I do it?

I have something like this:

```<code> public string EncryptPasswordRandom()
 {
         var password = // some random password, how can I generate it?
         var salt = // how can I generate it?

         using (var sha256 = SHA256.Create())
         {
              var saltedPassword = string.Format("{0}{1}", salt, password);
              byte[] saltedPasswordAsBytes = Encoding.UTF8.GetBytes(saltedPassword);
              return Convert.ToBase64String(sha256.ComputeHash(saltedPasswordAsBytes));
         }
 }
</code>```

Help is very appreciated. Regards

Note: I have a web application who works well, I can register user and
  login, this random password is for recovery password  and made one
  random

答:
System.Web.Membership has a GeneratePassword method that will do the job.

As for randomly generating the salt Guid.New() should work.

This answer addresses generating the salt in a high entropy fashion.

It might help if you explain what you are attempting to accomplish as well. At face value it looks like an odd requirement unless this is in a test of some sort.

Title: Set random Password and Salt

Body:
I want to create random password and salt.

Now I have a function based who Encrypt password like:

public string EncryptPassword(string password, string salt)
{
        using (var sha256 = SHA256.Create())
        {
             var saltedPassword = string.Format("{0}{1}", salt, password);
             byte[] saltedPasswordAsBytes = Encoding.UTF8.GetBytes(saltedPassword);
             return Convert.ToBase64String(sha256.ComputeHash(saltedPasswordAsBytes));
        }
}

So I want to do same encode password and salt but with random values, and before encode it I want to know what password is. How can I do it?

I have something like this:

 public string EncryptPasswordRandom()
 {
         var password = // some random password, how can I generate it?
         var salt = // how can I generate it?

         using (var sha256 = SHA256.Create())
         {
              var saltedPassword = string.Format("{0}{1}", salt, password);
              byte[] saltedPasswordAsBytes = Encoding.UTF8.GetBytes(saltedPassword);
              return Convert.ToBase64String(sha256.ComputeHash(saltedPasswordAsBytes));
         }
 }

Help is very appreciated. Regards

Note: I have a web application who works well, I can register user and
  login, this random password is for recovery password  and made one
  random


问:
Scrolling tableview resets horizontal scroll view page control
I have some odd behaviour in my app. I have a table view controller with static cells. In one of the cells I have a horizontal scroll view. The scroll view is connected to a page controller. The scroll view and page controller work fine however if I scroll the table view the scroll views page controller resets to the first page.

However, the actual scroll view contents do not so then if I scroll the scroll view again the page controller will jump back to the previous position.

I am using:

```<code>override func scrollViewDidEndDecelerating(scrollView: UIScrollView){
  let pageWidth:CGFloat = CGRectGetWidth(scrollView.frame)
  let currentPage:CGFloat = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1
   self.pageController.currentPage = Int(currentPage)
}
</code>```

to control the visuals of the page controller.

It seems like the above is also picking up the table view scroll did end. Any suggestions on how to stop the table view triggering the function?

Thanks

答:
This might be an old thread but you dont really need that tableview reference.</p>

```<code>if scrollView is UITableView{
    return
}
//Do some stuff
</code>```

Body:
I have some odd behaviour in my app. I have a table view controller with static cells. In one of the cells I have a horizontal scroll view. The scroll view is connected to a page controller. The scroll view and page controller work fine however if I scroll the table view the scroll views page controller resets to the first page.

However, the actual scroll view contents do not so then if I scroll the scroll view again the page controller will jump back to the previous position.

I am using:

override func scrollViewDidEndDecelerating(scrollView: UIScrollView){
  let pageWidth:CGFloat = CGRectGetWidth(scrollView.frame)
  let currentPage:CGFloat = floor((scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1
   self.pageController.currentPage = Int(currentPage)
}

to control the visuals of the page controller.

It seems like the above is also picking up the table view scroll did end. Any suggestions on how to stop the table view triggering the function?

Thanks

Body:
This might be an old thread but you dont really need that tableview reference.

if scrollView is UITableView{
    return
}
//Do some stuff


问:
Does Owin Middleware support setting JWT tokens in HttpOnly cookies?
I'm using The Microsoft.Owin.Security.Jwt provider for auth in a HTML5/ASP .NET application - to make it more secure, is there anyway to instruct the API to write/read the token to a HttpOnly and Secure (HTTPS) only cookie? At the moment, it's returning the token via the HTTP response body and expecting the token to be sent on the 'Authorization' header.

Thanks.

答: I do not think there is a free way to do this, you will have to do this yourself.</p>


问:
What's really more performant? Haskell or OCaml
I spent the last 18 months getting the grip of functional programming, starting with learning OCaml and for some weeks now Haskell. Now I want to take the next step and implement some actual application: A simple realtime terrain editor. I've written numerous realtime terrain rendering engines, so this is a familiar topic. And the used recursive algorithms and data structures seem very fit for a functional implementation.

With this being a realtime application I'm naturally looking for the best performance I can get. Now some proponents of OCaml quite frequently complain about Haskell being slow compared to OCaml or F#. But according to the The Computer Language Benchmarks Game Haskell oftenly beats OCaml, if only by rather small fractions. There remains the problem, that this benchmark takes only very specific samples.

The right thing to do would be to, of course, implement the program in both languages and compare them, but I simply don't want to do double the work.

But maybe other people did comparable applications in OCaml and Haskell and give some statistics?

答: Based on all the data I've seen, they are roughly comparable. The code you write will make a bigger difference than the language itself.</p>

ContentLicense: CC BY-SA 4.0


问:
How to get response from GET-request to API in okhttp?
How can i get some response from API through GET-request?

The way i'm sending GET:

```<code>    OkHttpClient client = new OkHttpClient();

    client.setConnectTimeout(5, TimeUnit.SECONDS);//Connect timeout
    client.setReadTimeout(5, TimeUnit.SECONDS);//Socket timeout

    Request request = new Request.Builder().url(String.valueOf(message)).build();
    Response response = client.newCall(request).execute();
</code>```

The way i'm trying to get response:

```<code>response.message();
</code>```

What i get:

```<code>OK
</code>```

What i need to get from API:

```<code>OK|ID (Example: OK|2122988149)
</code>```

答:
You should try: </p>

```<code>response.body().string()
</code>```

Body:
How can i get some response from API through GET-request?

The way i'm sending GET:

    OkHttpClient client = new OkHttpClient();

    client.setConnectTimeout(5, TimeUnit.SECONDS);//Connect timeout
    client.setReadTimeout(5, TimeUnit.SECONDS);//Socket timeout

    Request request = new Request.Builder().url(String.valueOf(message)).build();
    Response response = client.newCall(request).execute();

The way i'm trying to get response:

response.message();

What i get:

OK

What i need to get from API:

OK|ID (Example: OK|2122988149)

Body:
You should try:

response.body().string()


问:
Load data if connected to the Internet
Helle Stack community,

I created a simple app that loads a json and loads the data in a recyclerview.

The recyclerview includes cardviews.

The activity shows me a blank page if I haven't any internet connection,
but normally I want to see some blank cardviews like in the 9GAG app.

In the 9GAG app you get all data on swipe the display.

My app should load all data on internet connection is available. I googled something about broadcast receiver, but can't find a simple example for my need.

Maybe someone can show me a simple example or the way to do some action like in the 9GAG app. Info: The app is for api 21 User.

I would appreciate it.

答:
Use a BroadcastReceiver that gets notified, when the connection state changes. It is very important that you register it in your manifeset!

Add a class, similar to this to your project:

```<code>public class NetworkChangedReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Network state changed!
        // Check if the user connected using ConnectivityManager.getActiveNetworkInfo()
    }
}
</code>```

Add it to your manifest file, so the systems knows it should notify you:

```<code><manifest>
    ...
   <application>
       ...
       <receiver
            android:name=".NetworkChangedReceiver"
            android:process=":remote">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
            </intent-filter>
       </receiver>
       ...
    </application>
</manifest>
</code>```

Edit:
From the docs:

Apps targeting Android 7.0 (API level 24) do not receive CONNECTIVITY_ACTION broadcasts if they register to receive them in their manifest, and processes that depend on this broadcast will not start. This could pose a problem for apps that want to listen for network changes or perform bulk network activities when the device connects to an unmetered network. Several solutions to get around this restriction already exist in the Android framework, but choosing the right one depends on what you want your app to accomplish.

Note: A BroadcastReceiver registered with Context.registerReceiver()
  continues to receive these broadcasts while the app is running.

I didn't knew about this, so thanks to @Paul Nie for letting me know :D

I can't really help further at this point. But this seems like a good point to start some research about this topic: https://developer.android.com/topic/performance/background-optimization.html#connectivity-action

Title: Load data if connected to the Internet

Body:
Use a BroadcastReceiver that gets notified, when the connection state changes. It is very important that you register it in your manifeset!

Add a class, similar to this to your project:

public class NetworkChangedReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // Network state changed!
        // Check if the user connected using ConnectivityManager.getActiveNetworkInfo()
    }
}

Add it to your manifest file, so the systems knows it should notify you:

<manifest>
    ...
   <application>
       ...
       <receiver
            android:name=".NetworkChangedReceiver"
            android:process=":remote">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
            </intent-filter>
       </receiver>
       ...
    </application>
</manifest>

Edit:
From the docs:

Apps targeting Android 7.0 (API level 24) do not receive CONNECTIVITY_ACTION broadcasts if they register to receive them in their manifest, and processes that depend on this broadcast will not start. This could pose a problem for apps that want to listen for network changes or perform bulk network activities when the device connects to an unmetered network. Several solutions to get around this restriction already exist in the Android framework, but choosing the right one depends on what you want your app to accomplish.

Note: A BroadcastReceiver registered with Context.registerReceiver()
  continues to receive these broadcasts while the app is running.

I didn't knew about this, so thanks to @Paul Nie for letting me know :D

I can't really help further at this point. But this seems like a good point to start some research about this topic: https://developer.android.com/topic/performance/background-optimization.html#connectivity-action


问:
PDFBox creates PDF that is displayed differently in each browser
I am using PDFBox to create PDFs and i insert a "background" image on the PDF which is basically a curved border and some social network information.

Please find below the code i use to generate the PDF:

```<code> PDDocument document = new PDDocument();
    PDPage page = new PDPage();

    document.addPage(page);
    PDPageContentStream contentStream = new PDPageContentStream(document, page);

    PDImageXObject pdImage = PDImageXObject.createFromFile(basePath+"images/"+ticket.getId()+".png", document);
    PDImageXObject backgroundImage = PDImageXObject.createFromFile(basePath+"images/ticket_template.jpg",document);

    backgroundImage.setWidth(595);
    backgroundImage.setHeight(800);

    contentStream.drawImage(backgroundImage,10,0);
    contentStream.drawImage(pdImage,(page.getMediaBox().getWidth() - pdImage.getWidth()) / 2,page.getMediaBox().getHeight()-400);

    float margin = 50;
    // starting y position is whole page height subtracted by top and bottom margin
    float yStartNewPage = page.getMediaBox().getHeight() - (2 * margin);
    // we want table across whole page width (subtracted by left and right margin ofcourse)
    float tableWidth = page.getMediaBox().getWidth() - (2 * margin);

    boolean drawContent = true;
    float yStart = yStartNewPage;
    float bottomMargin = 70;
    // y position is your coordinate of top left corner of the table
    float yPosition = 550;
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");

    BaseTable table = new BaseTable(400, yStartNewPage, bottomMargin, tableWidth, margin, document, page, true, drawContent);
    generateTable(table,"Event",event.getName());
    generateTable(table,"Código",ticket.getId());
    generateTable(table,"Data Ínicio",dateFormat.format(event.getStartDate()));
    generateTable(table,"Data Fim",dateFormat.format(event.getEndDate()));
    generateTable(table,"Mesa",eventTable.getName());
    generateTable(table,"Número de Convidados",ticket.getNumberOfPeople()+"");

    table.draw();

    contentStream.close();

    document.save(new File(basePath+"docs/"+ticket.getId()+".pdf"));

    document.close();
</code>```

When the image is opened it chrome it seems to be misplaced:

I also seem to have issues inserting images with colors to the PDF and they also appear weird when converting the PDF to an image

答:
Browser approximate PDF rendering up to a point, this means the almost no browser implements exhaustively PDF specs.

This applies to almost every PDF rendering engine, the most truthful is naturally Adobe PDF reader, that is practically the reference implementation.

In the past browser used 3rd party plugins to embed PDF, but that brought security issues, to the point that now they do it themselves.

So you cannot completely rely on a single browser to be sure that your PDF will show correctly every time, it's a trial and error process ( that is also true for other software implementing PDF rendering, like PDF capable printers ).

The only sensible solution is to:

Try it first on Acrobat (it's at least the reference)

Check it with browsers and if they don't comply try to achieve the same result with different techniques.

PDF it's a very complex spec and there are a lot of different ways to get some result, try the simplest.

Body:
I am using PDFBox to create PDFs and i insert a "background" image on the PDF which is basically a curved border and some social network information.

Please find below the code i use to generate the PDF:

 PDDocument document = new PDDocument();
    PDPage page = new PDPage();

    document.addPage(page);
    PDPageContentStream contentStream = new PDPageContentStream(document, page);

    PDImageXObject pdImage = PDImageXObject.createFromFile(basePath+"images/"+ticket.getId()+".png", document);
    PDImageXObject backgroundImage = PDImageXObject.createFromFile(basePath+"images/ticket_template.jpg",document);

    backgroundImage.setWidth(595);
    backgroundImage.setHeight(800);

    contentStream.drawImage(backgroundImage,10,0);
    contentStream.drawImage(pdImage,(page.getMediaBox().getWidth() - pdImage.getWidth()) / 2,page.getMediaBox().getHeight()-400);

    float margin = 50;
    // starting y position is whole page height subtracted by top and bottom margin
    float yStartNewPage = page.getMediaBox().getHeight() - (2 * margin);
    // we want table across whole page width (subtracted by left and right margin ofcourse)
    float tableWidth = page.getMediaBox().getWidth() - (2 * margin);

    boolean drawContent = true;
    float yStart = yStartNewPage;
    float bottomMargin = 70;
    // y position is your coordinate of top left corner of the table
    float yPosition = 550;
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");

    BaseTable table = new BaseTable(400, yStartNewPage, bottomMargin, tableWidth, margin, document, page, true, drawContent);
    generateTable(table,"Event",event.getName());
    generateTable(table,"Código",ticket.getId());
    generateTable(table,"Data Ínicio",dateFormat.format(event.getStartDate()));
    generateTable(table,"Data Fim",dateFormat.format(event.getEndDate()));
    generateTable(table,"Mesa",eventTable.getName());
    generateTable(table,"Número de Convidados",ticket.getNumberOfPeople()+"");

    table.draw();

    contentStream.close();

    document.save(new File(basePath+"docs/"+ticket.getId()+".pdf"));

    document.close();

When the image is opened it chrome it seems to be misplaced:

I also seem to have issues inserting images with colors to the PDF and they also appear weird when converting the PDF to an image


问:
img tag not showing image
I created a text file using notepad with the following content, and save it with a html extension.  Then I open it in browser.  The image doesn't show. When I put the image URL in the browser the image shows up, so I know my link is correct.   What am I missing here?  Thanks in advance for your answer.</p>

```<code><!DOCTYPE html>
<html>
<body>

<p>Image doesn't show</p>

<img scr="https://www.findtaxpro.com/Content/img/logo.png" style="width:90px; height:90px;"/>

</body>
</html>
</code>```

答:
```<code><img scr="https://www.findtaxpro.com/Content/img/logo.png" style="width:90px; height:90px;"/>
</code>```

corrected spelling

```<code><img src="https://www.findtaxpro.com/Content/img/logo.png" style="width:90px; height:90px;"/>
</code>```

Title: img tag not showing image

Body:
I created a text file using notepad with the following content, and save it with a html extension.  Then I open it in browser.  The image doesn't show. When I put the image URL in the browser the image shows up, so I know my link is correct.   What am I missing here?  Thanks in advance for your answer.

<!DOCTYPE html>

Image doesn't show

Body:
<img scr="https://www.findtaxpro.com/Content/img/logo.png" style="width:90px; height:90px;"/>

corrected spelling

<img src="https://www.findtaxpro.com/Content/img/logo.png" style="width:90px; height:90px;"/>


问:
Trying to populate second dropdown menu from first dropdown menu php mysql
I am trying to populate 3 menus, 1st menu is created from mysql query and php and displays TVshows ( ie. Modern Family, Dexter, etc ), what I would like to do is once the TVShow is selected populate the next drop down with a new mysql query for seasons ( 1 ,2 ,3 etc.) , then populate a 3rd drop down via mysql query based off the first 2 options being selected for episode

The table is as follows
| id | Title  | Season | Episode | Extension | URL

I can get the first drop down to display with the following code

```<code><?php
$sql="Select distinct title from TVShows";
$result=mysql_query($sql);

echo "<select name='TVShow'><option value=''>Select TV Show</option>";
while($row = mysql_fetch_array($result))
{
echo    "<option value=$row[title]>$row[title]</option>";
}
echo "</select>";
?>
</code>```

I have tried many examples but none seem to work right, I would like to be able to do this on the same page as opposed to having the user click submit to go to another page to select the second drop down.

I would like code to dynamically setup the 2nd dropdown based on the first choice, then dynamically setup the 3rd dropdown based on the 1st and second dropdowns

答:
For better performance on the user end you might consider loading all results from the db (and then ideally caching them) and then hiding and showing the appropriate ones with javascript.

This way if users are clicking on your menu a lot you're not making a ton of unnecessary round trips to the db.

Body:
I am trying to populate 3 menus, 1st menu is created from mysql query and php and displays TVshows ( ie. Modern Family, Dexter, etc ), what I would like to do is once the TVShow is selected populate the next drop down with a new mysql query for seasons ( 1 ,2 ,3 etc.) , then populate a 3rd drop down via mysql query based off the first 2 options being selected for episode

The table is as follows
| id | Title  | Season | Episode | Extension | URL

I can get the first drop down to display with the following code

<?php
$sql="Select distinct title from TVShows";
$result=mysql_query($sql);

echo "<select name='TVShow'><option value=''>Select TV Show</option>";
while($row = mysql_fetch_array($result))
{
echo    "<option value=$row[title]>$row[title]</option>";
}
echo "</select>";
?>

I have tried many examples but none seem to work right, I would like to be able to do this on the same page as opposed to having the user click submit to go to another page to select the second drop down.

I would like code to dynamically setup the 2nd dropdown based on the first choice, then dynamically setup the 3rd dropdown based on the 1st and second dropdowns


问:
Geo coding google maps API with udacity
I recently started a google maps API course with Udacity, one of the questions involves geocoding and I have hit a brick wall with it.

the task that I have asked to do is "Using geocode WEB SERVICE request in your browser find the fun place that the following coordinate describes"

the coordinates being LAT:33.1262476 LNG:-117.3115765 the videos on the course didn't go into to much detail.

Any help?

答:
Read about Google's geocoding API, and in particular the reverse lookup of lat/long coordinates -> addresses and/or named locations.

https://developers.google.com/maps/documentation/geocoding/intro#reverse-example

For your case, it will be something like making a request to this URL:

```<code>https://maps.googleapis.com/maps/api/geocode/json?key=YOUR_API_KEY&latlng=33.1262476,-117.3115765
</code>```

Note that YOUR_API_KEY is something you'll have to create by registering a Google developer account (which is free).

Title: Geo coding google maps API with udacity

Body:
Read about Google's geocoding API, and in particular the reverse lookup of lat/long coordinates -> addresses and/or named locations.

https://developers.google.com/maps/documentation/geocoding/intro#reverse-example

For your case, it will be something like making a request to this URL:

https://maps.googleapis.com/maps/api/geocode/json?key=YOUR_API_KEY&latlng=33.1262476,-117.3115765

Note that YOUR_API_KEY is something you'll have to create by registering a Google developer account (which is free).


问:
How to override SqlCommand to grab generated TSQL
Is there any way to intercept the SQL that's generated by SqlCommand?

I currently have a method that will execute a stored procedure:

```<code>public int ExecSP(string spName, params objec[] params)
{
     using (SqlConnection con = new SqlConnection("AdventureWorks"))
     using (SqlCommand cmd = new SqlCommand(spName, con))
     {
         cmd.CommandType = CommandType.StoredProcedure;

        //..calls method to add params and values to cmd object

        con.Open();
        return cmd.ExecuteNonQuery();
     }
}
</code>```

When I use this to call the following:

ExecSP("HumanResources.uspUpdateEmployeePersonalInfo", 1, "295847284", new DateTime(1963, 3, 2), "S", "M");`

I get the following in SQLProfiler:

```<code>exec HumanResources.uspUpdateEmployeePersonalInfo @BusinessEntityID=1,@NationalIDNumber=N'295847284',@BirthDate='1963-03-02 00:00:00',@MaritalStatus=N'S',@Gender=N'M'
</code>```

What I would like to do is intercept that SQL command so that I may add a comment to the end of it that will contain some pertinent information so that it looks like:

```<code>exec HumanResources.uspUpdateEmployeePersonalInfo @BusinessEntityID=1,@NationalIDNumber=N'295847284',@BirthDate='1963-03-02 00:00:00',@MaritalStatus=N'S',@Gender=N'M' -- IMPORTANT INFORMATION HERE
</code>```

I can't change the CommandType to Text and I can't add an extra parameter to the stored procedure. I tried looking at these other questions but had no luck:

Can I override SqlCommand functions?

SqlCommand to T-SQL

答:
What you're seeing is a debug/profile message, but that doesn't perfectly represent what was actually executed (the database will use sp_executesql() behind the scenes).

What you are looking for doesn't exist. The whole point of using parameter objects is that parameter values are NEVER, at any time, included as part of the sql command string, even on the server.

This accomplishes three main things:

It prevents any possibility of sql injection attacks via that query. You'll never have a problem with some weird unicode character set problem allowing an attacker to insert a command into the data for your query, like they did a couple years back with php/mysql, or some new language feature creating a situation where your old escape code wasn't good enough. The user-data portion of a query is always separated from the command logic portion of the query at every stage.

It improves performance, by allowing the server to cache the execution plan. This saves compile steps as your application executes what may be the same query over and over, just with different parameter data.

It avoids problems with formatting for things like dates, text data with apostrophes, and the like.

If you want to get debugging data, write a method to output the query and the parameter data that goes with it. If you want to add info the your profile trace, you can switch to CommandType.Text and call the stored procedure via your own EXEC procedurename @param1, @param2, ... @paramN -- INFO HERE string.

Body:
Is there any way to intercept the SQL that's generated by SqlCommand?

I currently have a method that will execute a stored procedure:

public int ExecSP(string spName, params objec[] params)
{
     using (SqlConnection con = new SqlConnection("AdventureWorks"))
     using (SqlCommand cmd = new SqlCommand(spName, con))
     {
         cmd.CommandType = CommandType.StoredProcedure;

        //..calls method to add params and values to cmd object

        con.Open();
        return cmd.ExecuteNonQuery();
     }
}

When I use this to call the following:

ExecSP("HumanResources.uspUpdateEmployeePersonalInfo", 1, "295847284", new DateTime(1963, 3, 2), "S", "M");`

I get the following in SQLProfiler:

exec HumanResources.uspUpdateEmployeePersonalInfo @BusinessEntityID=1,@NationalIDNumber=N'295847284',@BirthDate='1963-03-02 00:00:00',@MaritalStatus=N'S',@Gender=N'M'

What I would like to do is intercept that SQL command so that I may add a comment to the end of it that will contain some pertinent information so that it looks like:

exec HumanResources.uspUpdateEmployeePersonalInfo @BusinessEntityID=1,@NationalIDNumber=N'295847284',@BirthDate='1963-03-02 00:00:00',@MaritalStatus=N'S',@Gender=N'M' -- IMPORTANT INFORMATION HERE

I can't change the CommandType to Text and I can't add an extra parameter to the stored procedure. I tried looking at these other questions but had no luck:

Can I override SqlCommand functions?

SqlCommand to T-SQL