问:
Select from same table, within IF statement
I am selecting a list from a table, and would like to include the parent's label if an item has a parent, or just - if it doesn't.

For this example the table structure is basic :

```<code>id | label | parent
</code>```

This is he statment I'm trying:

SELECT id, label,
    IF (parent > 0, (SELECT id FROM meta WHERE parent = m.id), '-') AS parent
    FROM meta AS m WHERE type = 'genre'

I'm getting [NULL] for parent when the item does have a parent. If I replace the IF statement with IF (parent > 0, 'Has parent', '-') AS parent the output is correct.

Is there a better way to do this?

答:
You could with a left join to itself. if the parent is present the parent label will be non-null, otherwise the '-' will be printed.</p>

```<code>SELECT
  m.id,
  m.label,
  COALESCE(parent.label, '-') AS parent
FROM
  meta AS m LEFT JOIN meta AS parent ON (m.parent = parent.id)
WHERE
  m.type = 'genre'
</code>```

Body:
I am selecting a list from a table, and would like to include the parent's label if an item has a parent, or just - if it doesn't.

For this example the table structure is basic :

id | label | parent

This is he statment I'm trying:

SELECT id, label,
    IF (parent > 0, (SELECT id FROM meta WHERE parent = m.id), '-') AS parent
    FROM meta AS m WHERE type = 'genre'

I'm getting [NULL] for parent when the item does have a parent. If I replace the IF statement with IF (parent > 0, 'Has parent', '-') AS parent the output is correct.

Is there a better way to do this?

Body:
You could with a left join to itself. if the parent is present the parent label will be non-null, otherwise the '-' will be printed.

SELECT
  m.id,
  m.label,
  COALESCE(parent.label, '-') AS parent
FROM
  meta AS m LEFT JOIN meta AS parent ON (m.parent = parent.id)
WHERE
  m.type = 'genre'


来源: stackexchange

问:
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=350m;
When I'mtrying to open Intellij IDE using command line in linux like this ./phpstorm.sh both android studio and PHPStorm I always got this message :

OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=350m;
  support was removed in 8.0

and I was wondering if google find solution here but I was kinda lost here since I'm newbie in ubuntu 14.04. my question is what is the cause of this message to diplay? and how to resolve this?

I've tried using this command export MAVEN_OPTS="-Xmx512m" but it's not resolve the issue.
and I'm using java 1.8.0_73 downloaded from here. any useful help would be appreciated, thank you.

答:
For me I fixed same issue by adding _JAVA_OPTIONS: -Xmx6G to the enviroment variable
Windows 8.1
java version 1.7.0_79</p>

ContentLicense: CC BY-SA 3.0


问:
Java Keytool error after importing certificate , "keytool error: java.io.FileNotFoundException & Access Denied"
I'm trying to connect a Java Web API via HTTPS; however, an exception is thrown:

```<code>javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException
</code>```

I followed these steps which I learned from online keytool & SSL cert tutorials:

I copied the HTTPS URL into the browser, downloaded the SSL certificates & Installed them in the browser using Internet Explorer.

Exported the certificates to a path on my computer, the certificates were saved as .cer

Used the keytool's import option. The command below executed without any errors.

```<code>keytool -import -alias downloadedCertAlias -keystore C:\path\to\my\keystore\cacerts.file -file C:\path\of\exportedCert.cer
</code>```

I was prompted for a password at the command prompt, which I entered then I was authenticated.

The cmd window printed some certificate data & signatures and I was prompted with the question:

Trust this certificate?

I answered yes.

The cmd prompt displayed

Certificate was added to keystore

However after that message, another exception was displayed:

```<code>keytool error: java.io.FileNotFoundException: C:\Program files\...\cacerts <Access Denied>
</code>```

Finally when I checked the keystore , the SSL certificate was not added and my application gives the same exception I was getting earlier when trying to connect:

```<code>(javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException)
</code>```

答:
I was having the same problem while importing the certificate in local keystore. Whenever i issue the keytool command i got the following error.

Certificate was added to keystore
keytool error: java.io.FileNotFoundException: C:\Program Files\Java\jdk1.8.0_151\jre\lib\security (Access is denied)

Following solution work for me.

1) make sure you are running command prompt in Rus as Administrator mode

2) Change your current directory to %JAVA_HOME%\jre\lib\security

3) then Issue the below command

keytool -import -alias "mycertificatedemo" -file "C:\Users\name\Downloads\abc.crt" -keystore cacerts

3) give the password changeit

4) enter y

5) you will see the following message on successful
"Certificate was added to keystore"

Make sure you are giving the "cacerts" only in -keystore param value , as i was giving the full path like "C**:\Program Files\Java\jdk1.8.0_151\jre\lib\security**".

Hope this will work

Body:
I'm trying to connect a Java Web API via HTTPS; however, an exception is thrown:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException

I followed these steps which I learned from online keytool & SSL cert tutorials:

I copied the HTTPS URL into the browser, downloaded the SSL certificates & Installed them in the browser using Internet Explorer.

Exported the certificates to a path on my computer, the certificates were saved as .cer

Used the keytool's import option. The command below executed without any errors.

keytool -import -alias downloadedCertAlias -keystore C:\path\to\my\keystore\cacerts.file -file C:\path\of\exportedCert.cer

I was prompted for a password at the command prompt, which I entered then I was authenticated.

The cmd window printed some certificate data & signatures and I was prompted with the question:

Trust this certificate?

I answered yes.

The cmd prompt displayed

Certificate was added to keystore

However after that message, another exception was displayed:

keytool error: java.io.FileNotFoundException: C:\Program files\...\cacerts <Access Denied>

Finally when I checked the keystore , the SSL certificate was not added and my application gives the same exception I was getting earlier when trying to connect:

(javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException)


问:
EMGUCV fastest set pixel
I Need fastest way to iterate an EmguCV bitmap matrix and set pixel. i found this after google but it takes about 3 sec for 700x500 image:

Documents says that access (get) data matrix is just o(1) but its not clearly declare about set data.

```
<code>

    for(int i = 0; i < img.Rows ; i++)

        for(int j = 0; j < img.Cols; j++){

            img.Data[x,y,0] = 255;

            img.Data[x,y,1] = 255;

            img.Data[x,y,2] = 255;

        }

</code>
```

Thanks in advance.

答:
Here is a method I use to replace color, it replaces any color given that is not within a given (difference) to the desired one. Its very fast, uses unsafe</p>

```<code>/// <summary>
    /// Replaces a given color in a bitmap
    /// </summary>
    /// <param name="image"></param>
    /// <returns></returns>
    public static unsafe void ReplaceColor(Bitmap image,
        Color FindColor,
        int WithinDistance,
        Color ReplaceColor
        )
    {

        byte FindColorR = (byte)FindColor.R;
        byte FindColorG = (byte)FindColor.G;
        byte FindColorB = (byte)FindColor.B;

        byte ReplaceColorR = (byte)ReplaceColor.R;
        byte ReplaceColorG = (byte)ReplaceColor.G;
        byte ReplaceColorB = (byte)ReplaceColor.B;

        byte WithinDistanceByte = (byte)WithinDistance;

        BitmapData imageData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
            ImageLockMode.ReadWrite,
            PixelFormat.Format24bppRgb);

        int bytesPerPixel = 3;
        byte* scan0 = (byte*)imageData.Scan0.ToPointer();
        int stride = imageData.Stride;
        PixelData NewData = new PixelData(image.Height,image.Size);
        for (int y = 0; y < imageData.Height; y++)
        {
            byte* row = scan0 + (y * stride);
            for (int x = 0; x < imageData.Width; x++)
            {
                int bIndex = x * bytesPerPixel;
                int gIndex = bIndex + 1;
                int rIndex = bIndex + 2;

                byte pixelR = row[rIndex];
                byte pixelG = row[gIndex];
                byte pixelB = row[bIndex];

                if( Math.Abs(FindColorR - pixelR) > WithinDistanceByte &&
                    Math.Abs(FindColorG - pixelG) > WithinDistanceByte &&
                    Math.Abs(FindColorB - pixelB) > WithinDistanceByte )
                {
                    row[rIndex] = ReplaceColorR;
                    row[gIndex] = ReplaceColorG;
                    row[bIndex] = ReplaceColorB;
                }
                else
                {
                    row[rIndex] = FindColorR;
                    row[gIndex] = FindColorG;
                    row[bIndex] = FindColorB;
                }
            }
        }
        image.UnlockBits(imageData);
    }
</code>```

Title: EMGUCV fastest set pixel

Body:
I Need fastest way to iterate an EmguCV bitmap matrix and set pixel. i found this after google but it takes about 3 sec for 700x500 image:

Documents says that access (get) data matrix is just o(1) but its not clearly declare about set data.

    for(int i = 0; i < img.Rows ; i++)

        for(int j = 0; j < img.Cols; j++){

            img.Data[x,y,0] = 255;

            img.Data[x,y,1] = 255;

            img.Data[x,y,2] = 255;

        }

Thanks in advance.

Body:
Here is a method I use to replace color, it replaces any color given that is not within a given (difference) to the desired one. Its very fast, uses unsafe

/// <summary>
    /// Replaces a given color in a bitmap
    /// </summary>
    /// <param name="image"></param>
    /// <returns></returns>
    public static unsafe void ReplaceColor(Bitmap image,
        Color FindColor,
        int WithinDistance,
        Color ReplaceColor
        )
    {

        byte FindColorR = (byte)FindColor.R;
        byte FindColorG = (byte)FindColor.G;
        byte FindColorB = (byte)FindColor.B;

        byte ReplaceColorR = (byte)ReplaceColor.R;
        byte ReplaceColorG = (byte)ReplaceColor.G;
        byte ReplaceColorB = (byte)ReplaceColor.B;

        byte WithinDistanceByte = (byte)WithinDistance;

        BitmapData imageData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
            ImageLockMode.ReadWrite,
            PixelFormat.Format24bppRgb);

        int bytesPerPixel = 3;
        byte* scan0 = (byte*)imageData.Scan0.ToPointer();
        int stride = imageData.Stride;
        PixelData NewData = new PixelData(image.Height,image.Size);
        for (int y = 0; y < imageData.Height; y++)
        {
            byte* row = scan0 + (y * stride);
            for (int x = 0; x < imageData.Width; x++)
            {
                int bIndex = x * bytesPerPixel;
                int gIndex = bIndex + 1;
                int rIndex = bIndex + 2;

                byte pixelR = row[rIndex];
                byte pixelG = row[gIndex];
                byte pixelB = row[bIndex];

                if( Math.Abs(FindColorR - pixelR) > WithinDistanceByte &&
                    Math.Abs(FindColorG - pixelG) > WithinDistanceByte &&
                    Math.Abs(FindColorB - pixelB) > WithinDistanceByte )
                {
                    row[rIndex] = ReplaceColorR;
                    row[gIndex] = ReplaceColorG;
                    row[bIndex] = ReplaceColorB;
                }
                else
                {
                    row[rIndex] = FindColorR;
                    row[gIndex] = FindColorG;
                    row[bIndex] = FindColorB;
                }
            }
        }
        image.UnlockBits(imageData);
    }


问:
'The matching wildcard is strict, but no declaration can be found' Error connecting mongodb to spring
I'm trying to connect Spring to Mongodb. But it doesn't work somehow. In general, I've used Spring core 5.0.1, Spring data 2.0.1 ang Mongdodb driver 3.5.0. I also used the tag mongo:mongo-client host="localhost" port="27017" in creating an MongoDb Template bean. The dependencies were fully downloaded but probems still happened.
Please help. Here is the files:

SpringConfig.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mongo="http://www.springframework.org/schema/data/mongo"
      xsi:schemaLocation=
      "http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <mongo:mongo-client host="localhost" port="27017"/>

    <mongo:db-factory dbname="WebDB" />

</beans>
</code>```

App.class

```<code>package com.erc.myspring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.data.mongodb.core.MongoTemplate;

public class App {

    public static void main(String[] args) {
        ApplicationContext ctx = new GenericXmlApplicationContext("SpringConfig.xml");
        MongoTemplate mongoOperation = (MongoTemplate)ctx.getBean("mongoTemplate");
    }

}
</code>```

pom.xml (if neccesary)

```<code><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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.erc</groupId>
    <artifactId>WebCom</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>WebCom Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <spring.version>5.0.1.RELEASE</spring.version>
        <spring.data.version>2.0.1.RELEASE</spring.data.version>
        <mongodb.version>3.5.0</mongodb.version>
        <cxf.version>2.5.0</cxf.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>hamcrest-core</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>1.3.0</version>
            <scope>test</scope>
        </dependency>

        <!-- Spring MVC -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!--Data mongodb -->

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>2.0.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>${mongodb.version}</version>
        </dependency>

        <!-- Json -->

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

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.skyscreamer</groupId>
            <artifactId>jsonassert</artifactId>
            <version>1.2.3</version>
        </dependency>

        <!-- Servlet -->

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <!-- Apache Commons Upload -->
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.2</version>
        </dependency>

        <!-- Apache Commons Upload -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>

        <!-- Log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <!-- Swagger -->
        <dependency>
            <groupId>com.mangofactory</groupId>
            <artifactId>swagger-springmvc</artifactId>
            <version>0.8.8</version>
        </dependency>

        <dependency>
            <groupId>org.ajar</groupId>
            <artifactId>swagger-spring-mvc-ui</artifactId>
            <version>0.1</version>
            <scope>compile</scope>
        </dependency>

    </dependencies>

    <repositories>
        <repository>
            <id>jcenter-release</id>
            <name>jcenter</name>
            <url>http://oss.jfrog.org/artifactory/oss-release-local/</url>
        </repository>
    </repositories>
    <build>
        <finalName>WebCom</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

and the error message:

```<code>Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from class path resource [SpringConfig.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 56; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mongo:mongo-client'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    (+ 7 at something sentences)
    at com.erc.myspring.App.main(App.java:11)
Caused by: org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 56; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mongo:mongo-client'.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    (+20 at something sentences)
    ... 9 more
</code>```

The problem may refer to the line 'mongo:mongo-client...' in SpringConfig.xml, but I haven't found any way to fix that - since 2 days ago. Thank you very much.

答:
You can try to replace the schema declaration

```<code>http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
</code>```

with

```<code>http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
</code>```

Body:
I'm trying to connect Spring to Mongodb. But it doesn't work somehow. In general, I've used Spring core 5.0.1, Spring data 2.0.1 ang Mongdodb driver 3.5.0. I also used the tag mongo:mongo-client host="localhost" port="27017" in creating an MongoDb Template bean. The dependencies were fully downloaded but probems still happened.
Please help. Here is the files:

SpringConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xmlns:mongo="http://www.springframework.org/schema/data/mongo"
      xsi:schemaLocation=
      "http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-3.0.xsd
      http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <mongo:mongo-client host="localhost" port="27017"/>

    <mongo:db-factory dbname="WebDB" />

</beans>

App.class

package com.erc.myspring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.data.mongodb.core.MongoTemplate;

public class App {

    public static void main(String[] args) {
        ApplicationContext ctx = new GenericXmlApplicationContext("SpringConfig.xml");
        MongoTemplate mongoOperation = (MongoTemplate)ctx.getBean("mongoTemplate");
    }

}

pom.xml (if neccesary)

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.erc</groupId>
    <artifactId>WebCom</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>WebCom Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <spring.version>5.0.1.RELEASE</spring.version>
        <spring.data.version>2.0.1.RELEASE</spring.data.version>
        <mongodb.version>3.5.0</mongodb.version>
        <cxf.version>2.5.0</cxf.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>hamcrest-core</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>1.3.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-mongodb</artifactId>
            <version>2.0.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>${mongodb.version}</version>
        </dependency>

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

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.skyscreamer</groupId>
            <artifactId>jsonassert</artifactId>
            <version>1.2.3</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.2.2</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>com.mangofactory</groupId>
            <artifactId>swagger-springmvc</artifactId>
            <version>0.8.8</version>
        </dependency>

        <dependency>
            <groupId>org.ajar</groupId>
            <artifactId>swagger-spring-mvc-ui</artifactId>
            <version>0.1</version>
            <scope>compile</scope>
        </dependency>

    </dependencies>

    <repositories>
        <repository>
            <id>jcenter-release</id>
            <name>jcenter</name>
            <url>http://oss.jfrog.org/artifactory/oss-release-local/</url>
        </repository>
    </repositories>
    <build>
        <finalName>WebCom</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

and the error message:

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 13 in XML document from class path resource [SpringConfig.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 56; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mongo:mongo-client'.
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    (+ 7 at something sentences)
    at com.erc.myspring.App.main(App.java:11)
Caused by: org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 56; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mongo:mongo-client'.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    (+20 at something sentences)
    ... 9 more

The problem may refer to the line 'mongo:mongo-client...' in SpringConfig.xml, but I haven't found any way to fix that - since 2 days ago. Thank you very much.

Body:
You can try to replace the schema declaration

http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd

with

http://www.springframework.org/schema/data/mongo/spring-mongo.xsd


问:
logistic regression cost function scikit learn
So I've done a coursera ml course, and now i am looking at scikit-learn logistic regression which is a little bit different. I've been using sigmoid function and a cost function was divided to two separate cases when y=0 and y=1. But scikit learn have one function(I've found out that this is Generalised logistic function) which really don't make sense for me.

http://scikit-learn.org/stable/_images/math/760c999ccbc78b72d2a91186ba55ce37f0d2cf37.png
I am sorry i don't have enough reputation to post image.

So the main concern of the function is the case when y=0, than the cost function always have this log(e^0+1) value, so it does not matter what was the X or w. Can someone explain me that ?

答:
If I am correct the $y_i$ you have in this formula can only assume the values -1 or 1 (as derived in the link given by @jinyu0310). Normally you use this cost function (with regularisation)

(sorry for the equation inserted as image, but cannot use latex here, the image comes from goo.gl/M53u44)

So you always have the two terms that plays a role when yi = 0 or when yi=1. I am trying to find a better explanation on the notation that scikit uses in this formula but so far no luck.

Hope that helps you. Is just another way of writing the cost function with a regularisation factor. Keep also in mind that a constant factor in front of everything will not play a role in the optimisation process. Since you want to find the minimum and are not interested in overall factors that multiply everything.


问:
Regex match $-char only as pairs
I have the following regex for checking a string which have to start and end with $:

^[$][\w:$]+[$]$

This just works fine for strings like:

$Hello_World$

$Test$123$

Now I want the regex also to check if there is a $ between the leading and the ending $ it should only be allowed if the '$'-chars appear as couples like:

$Hello$Test$World$

This would be ok.

$Hello$World$

Should not be ok.

I tried it with the following:

```<code>^[$][\w:($)\2]+[$]$
</code>```

But unfortunately this doesn't work like expected.

Any ideas?

答:
You may consider a regex like

```<code>^[$][\w:]+(?:[$][\w:]+[$][\w:]+)*[$]$
</code>```

See the regex demo

If the parts between $ can be empty and $$$$ is also valid, replace + after [\w:] with * to allow 0 or more reptitions.

Details

^ - start of string

[$] - a $ symbol (in many cases, it is enough to write \$ or \\$)

[\w:]+ - 1 or more word chars or/and colons

(?:[$][\w:]+[$][\w:]+)* - (or (?:(?:[$][\w:]+){2})*) 0+ repetitions of 2 occurrences of:

[$] - $ char

[\w:]+ -  1 or more word chars or/and colons

[$] - a $ char

$ - end of string.

Title: Regex match $-char only as pairs

Body:
I have the following regex for checking a string which have to start and end with $:

^[$][\w:$]+[$]$

This just works fine for strings like:

$Hello_World$

$Test$123$

Now I want the regex also to check if there is a $ between the leading and the ending $ it should only be allowed if the '$'-chars appear as couples like:

$Hello$Test$World$

This would be ok.

$Hello$World$

Should not be ok.

I tried it with the following:

^[$][\w:($)\2]+[$]$

But unfortunately this doesn't work like expected.

Any ideas?

Body:
You may consider a regex like

^[$][\w:]+(?:[$][\w:]+[$][\w:]+)*[$]$

See the regex demo

If the parts between $ can be empty and $$$$ is also valid, replace + after [\w:] with * to allow 0 or more reptitions.

Details

^ - start of string

[$] - a $ symbol (in many cases, it is enough to write \$ or \\$)

[\w:]+ - 1 or more word chars or/and colons

(?:[$][\w:]+[$][\w:]+)* - (or (?:(?:[$][\w:]+){2})*) 0+ repetitions of 2 occurrences of:

[$] - $ char

[\w:]+ -  1 or more word chars or/and colons

[$] - a $ char

$ - end of string.


问:
apache creates more then one process
I am running django application in apache using mod wsgi. I have set server limit to 1 as of the following configuration.

00-mpm.conf

```<code><IfModule worker.c>
    StartServers         1
    ServerLimit          1
    #MaxClients         300
    MinSpareThreads     25
    MaxSpareThreads     75
    ThreadsPerChild     25
    MaxRequestsPerChild  0
</IfModule>
</code>```

At beginning apache runs with one server. But after some time when i am checking it runs with two servers. And i got the following error in the error.log

```<code>[mpm_worker:notice] [pid 46754:tid 139924109117568] AH00297: SIGUSR1 received.  Doing graceful restart.
</code>```

How can i make sure that apache to run with only one server. And not doing restart.

答:
Apache runs a parent process and then one child worker process with that configuration. The parent process would be quite small in size as all it is doing is managing the child worker process and restarts it if it dies etc. Requests are only handled by the child worker process. So what you are seeing is normal.

Why are you trying to restrict it to one process? If it is to satisfy some requirement of your WSGI application that can only have one process, you should not be using embedded mode anyway. Use daemon mode of mod_wsgi, in which case the WSGI application will use one process by default.

So put back the Apache MPM settings and then use:

```<code>WSGIRestrictEmbedded On

WSGIDaemonProcess myapp
WSGIScriptAlias / /some/path/myapp.wsgi process-group=myapp application-group=%{GLOBAL}
</code>```

This will result in the Apache parent process, however many child worker process Apache needs to accept and proxy requests, and the single mod_wsgi daemon process running the WSGI application, to which the child worker processes are proxying requests.

Title: apache creates more then one process

Body:
I am running django application in apache using mod wsgi. I have set server limit to 1 as of the following configuration.

00-mpm.conf

<IfModule worker.c>
    StartServers         1
    ServerLimit          1
    #MaxClients         300
    MinSpareThreads     25
    MaxSpareThreads     75
    ThreadsPerChild     25
    MaxRequestsPerChild  0
</IfModule>

At beginning apache runs with one server. But after some time when i am checking it runs with two servers. And i got the following error in the error.log

[mpm_worker:notice] [pid 46754:tid 139924109117568] AH00297: SIGUSR1 received.  Doing graceful restart.

How can i make sure that apache to run with only one server. And not doing restart.

Body:
Apache runs a parent process and then one child worker process with that configuration. The parent process would be quite small in size as all it is doing is managing the child worker process and restarts it if it dies etc. Requests are only handled by the child worker process. So what you are seeing is normal.

Why are you trying to restrict it to one process? If it is to satisfy some requirement of your WSGI application that can only have one process, you should not be using embedded mode anyway. Use daemon mode of mod_wsgi, in which case the WSGI application will use one process by default.

So put back the Apache MPM settings and then use:

WSGIRestrictEmbedded On

WSGIDaemonProcess myapp
WSGIScriptAlias / /some/path/myapp.wsgi process-group=myapp application-group=%{GLOBAL}

This will result in the Apache parent process, however many child worker process Apache needs to accept and proxy requests, and the single mod_wsgi daemon process running the WSGI application, to which the child worker processes are proxying requests.


问:
Excel: OLE DB Oracle connection - Save Password for refresh
So, I'm using an Excel file that contains several connections to an Oracle database targetting different SQL views. All the views are on the same server for the same user. The problem is, everytime I refresh the datas on the excel ("refresh all"), I have to enter the password for every connection, in my case, one connection = one view. Is there any way to either type in the password only one time when the data needs to be refreshed or either make the excel file retains the user's password.

Thanks for your time

答: Ok, I've found it. In excel, in the data tab -> Connections -> properties (of a connection) -> Definition tab, there is a check box to save the password. However it's saved without encryption, so be careful. </p>


问:
All methods return '.autoNumeric is not a function - Can't unformat numbers
I'm trying to get the raw values of input numbers formatted using autoNumeric, but can't because every method I try to do this with it returning '.autoNumeric is not a function' in the console.

$(document).ready(function() {

    new AutoNumeric('#input',  AutoNumeric.getPredefinedOptions().numericPos.dotDecimalCharCommaSeparator);

    $('#input').on('keyup', function() {
     $('#output').val($('#input').autoNumeric('getString'));
    })
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-resource.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/autonumeric/4.0.3/autoNumeric.js"></script>

<input id="input" name="basicPayPerYearInput" type="text" value="123456.78" placeholder="0.00" class="currencyInput validate">

<input type="text" for="basicPayPerYearInput" id="output"></code>```

I can't even initialise inputs properly as written in most of the documentation using $(selector).autoNumeric(), so I've had to use the above 'new AutoNumeric', which is strangely also used in some documentation and is the only way that works:

答:
@Terry answer is completely right regarding the question asked, however I recommend not using an event listener on your #input keyup event, since AutoNumeric does not always update the element value on each keyup, for instance when a bad key is entered by the user, ie. the key A.

If you want to update your #output element with the numeric string only when it really change, then you should listen to the custom event 'autoNumeric:rawValueModified', so:

instead of:

```<code>$('#input').on('keyup', function() {
    $('#output').val(autoNumericInstance.getNumericString());
});
</code>```

you should use:

```<code>const outputElm = document.querySelector('#output');
const inputElm = document.querySelector('#input');
inputElm.addEventListener('autoNumeric:rawValueModified', e => {
    outputElm.value = e.newRawValue;
});
</code>```

The documentation about the custom events sent by AutoNumeric.
Also checkout how you can add callbacks to all the get* functions.

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to get the raw values of input numbers formatted using autoNumeric, but can't because every method I try to do this with it returning '.autoNumeric is not a function' in the console.

$(document).ready(function() {

    new AutoNumeric('#input',  AutoNumeric.getPredefinedOptions().numericPos.dotDecimalCharCommaSeparator);

    $('#input').on('keyup', function() {
     $('#output').val($('#input').autoNumeric('getString'));
    })
})

<input id="input" name="basicPayPerYearInput" type="text" value="123456.78" placeholder="0.00" class="currencyInput validate">

<input type="text" for="basicPayPerYearInput" id="output">

I can't even initialise inputs properly as written in most of the documentation using $(selector).autoNumeric(), so I've had to use the above 'new AutoNumeric', which is strangely also used in some documentation and is the only way that works:

Body:
@Terry answer is completely right regarding the question asked, however I recommend not using an event listener on your #input keyup event, since AutoNumeric does not always update the element value on each keyup, for instance when a bad key is entered by the user, ie. the key A.

If you want to update your #output element with the numeric string only when it really change, then you should listen to the custom event 'autoNumeric:rawValueModified', so:

instead of:

$('#input').on('keyup', function() {
    $('#output').val(autoNumericInstance.getNumericString());
});

you should use:

const outputElm = document.querySelector('#output');
const inputElm = document.querySelector('#input');
inputElm.addEventListener('autoNumeric:rawValueModified', e => {
    outputElm.value = e.newRawValue;
});

The documentation about the custom events sent by AutoNumeric.
Also checkout how you can add callbacks to all the get* functions.


问:
A network related or instance specific error-26 while deploying MVC5 app to Windows server 2012 and Migration
Please don't mark it as duplicate tried out few of these similar errors already .

Scenario :

Just tried to deploy the MVC5 Entity Framework Code First Migration to a Windows 2012 Server which initially worked as without Styles/JS running so redeployed it changing the Bundling names ( this have no chance to be related with the current issue but stating it here). The CodeFirst DB gets created properly and the publish is successful but not able launch the app, it throws this error.

WebConfig Connectionstring:

```<code><connectionStrings>

    <add name="ERPContext_DatabasePublish" connectionString="Data Source=TSSERVER;Initial Catalog=TS_ERP;User ID=tssql;Password=*******"  providerName="System.Data.SqlClient" />
  </connectionStrings>
</code>```

TroubleShoot:

Checked SQL Services are running ( also Sql Server Browse )

Checked Connection String /Credentials( if its wrong the DB itself wont have created at first place by Migration

Manually able to log into the SQlServerStudio using same credentials

Was working fine in the initial deployment without any problem

DB user instance has admin rights

IIS configurations are defaults

Would that mean its related to any Firewall or Port ( 1433/1434) issues? But since the initial deployment was successful the Server/Network admin team has rejected that request to investigate.

Is there any chance that there are multiple references of connectionstrings for Entity Framework etc. I had check the IIS virtual directory connections too.
The application deployed ( web server) and SQlServer runs on the same server machine so the SQL remote also doesn't seems to be the issue here.

Appreciate any thoughts regarding the  same.

Apologies for posting the full error stack just in case if it has more hints

A network-related or instance-specific error occurred while
   establishing a connection to SQL Server. The server was not found or
  was not accessible. Verify that the instance name is correct and that
  SQL Server is configured to allow remote connections. (provider: SQL
  Network Interfaces, error: 26 - Error Locating Server/Instance
  Specified)[SqlException (0x80131904):    >System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
  owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
  allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
  userOptions, DbConnectionInternal& connection) +350

  System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
  owningObject, TaskCompletionSource1 retry, DbConnectionOptions
  userOptions, DbConnectionInternal& connection) +156

  System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
  owningConnection, TaskCompletionSource1 retry, DbConnectionOptions
  userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
  connection) +268

  System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
  outerConnection, DbConnectionFactory connectionFactory,
  TaskCompletionSource1 retry, DbConnectionOptions userOptions) +314

  System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
  retry) +204

  System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1
  retry) +428

  System.Data.SqlClient.SqlConnection.OpenAsync(CancellationToken
  cancellationToken) +572

  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.SqlServer.<<ExecuteAsync>b__3>d__6.MoveNext() +292
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.SqlServer.<ExecuteAsyncImplementation>d__91.MoveNext()
  +503    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.Core.EntityClient.d__8.MoveNext() +924

[EntityException: The underlying provider failed on Open.]

  System.Data.Entity.Core.EntityClient.d__8.MoveNext() +1255
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.Core.Objects.d__9.MoveNext()
  +514    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.Core.Objects.d__3d1.MoveNext()
  +312    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.SqlServer.<ExecuteAsyncImplementation>d__91.MoveNext()
  +579    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    System.Data.Entity.Utilities.CultureAwaiter1.GetResult()
  +48    System.Data.Entity.Core.Objects.<GetResultsAsync>d__e.MoveNext() +734
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    System.Data.Entity.Utilities.CultureAwaiter1.GetResult()
  +48    System.Data.Entity.Internal.d__0.MoveNext() +332    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.Infrastructure.d__251.MoveNext()
  +371    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    Microsoft.AspNet.Identity.CultureAwaiter1.GetResult()
  +48    Microsoft.AspNet.Identity.d__13.MoveNext() +438    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    Microsoft.AspNet.Identity.CultureAwaiter1.GetResult()
  +48    Microsoft.AspNet.Identity.<RoleExistsAsync>d__d.MoveNext() +403    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    Microsoft.AspNet.Identity.AsyncHelper.RunSync(Func1
  func) +232    ERPLite.Startup.CreateRolesandUsers() in
  C:\Users\trss\source\repos\ERP\ERP\Startup.cs:36

  ERPLite.Startup.Configuration(IAppBuilder app) in
  C:\Users\trss\source\repos\ERP\ERP\Startup.cs:22

[TargetInvocationException: Exception has been thrown by the target of
  an invocation.]    System.RuntimeMethodHandle.InvokeMethod(Object
  target, Object[] arguments, Signature sig, Boolean constructor) +0

  System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
  Object[] parameters, Object[] arguments) +128

  System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
  invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  +146    Owin.Loader.<>c__DisplayClass12.b__b(IAppBuilder builder) +93

  Owin.Loader.<>c__DisplayClass1.b__0(IAppBuilder
  builder) +209

  Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1
  startup) +842

  Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 startup) +51
  Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint()
  +101    System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
  +136    Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication
  context) +162

  System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
  appContext, HttpContext context, MethodInfo[] handlers) +583

  System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
  MethodInfo[] handlers, IntPtr appContext, HttpContext context) +169

  System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
  appContext, HttpContext context) +396

  System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
  appContext) +333

[HttpException (0x80004005): Exception has been thrown by the target
  of an invocation.]

  System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525

  System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
  +124    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
  wr, HttpContext context) +700

答:
Posting this for those who encounter this error and already checked the list of troubleshooting points mentioned in the question.

Once creating a publish/deployment using WebDeploy it will add 1 more connection string in the target webconfig as _DatabasePublish (refer question) apart from the existing local connectionString.

I assumed that the _DatabasePublish would be used by the published app but it requires both the connectionStrings pointed to the same DB.
While creating the EF Migration it used _DatabasePublish and subsequent ( Seeding etc) used the other connectionString. But I'm sure there should be ways to change this though.

Body:
Please don't mark it as duplicate tried out few of these similar errors already .

Scenario :

Just tried to deploy the MVC5 Entity Framework Code First Migration to a Windows 2012 Server which initially worked as without Styles/JS running so redeployed it changing the Bundling names ( this have no chance to be related with the current issue but stating it here). The CodeFirst DB gets created properly and the publish is successful but not able launch the app, it throws this error.

WebConfig Connectionstring:

<connectionStrings>

    <add name="ERPContext_DatabasePublish" connectionString="Data Source=TSSERVER;Initial Catalog=TS_ERP;User ID=tssql;Password=*******"  providerName="System.Data.SqlClient" />
  </connectionStrings>

TroubleShoot:

Checked SQL Services are running ( also Sql Server Browse )

Checked Connection String /Credentials( if its wrong the DB itself wont have created at first place by Migration

Manually able to log into the SQlServerStudio using same credentials

Was working fine in the initial deployment without any problem

DB user instance has admin rights

IIS configurations are defaults

Would that mean its related to any Firewall or Port ( 1433/1434) issues? But since the initial deployment was successful the Server/Network admin team has rejected that request to investigate.

Is there any chance that there are multiple references of connectionstrings for Entity Framework etc. I had check the IIS virtual directory connections too.
The application deployed ( web server) and SQlServer runs on the same server machine so the SQL remote also doesn't seems to be the issue here.

Appreciate any thoughts regarding the  same.

Apologies for posting the full error stack just in case if it has more hints

A network-related or instance-specific error occurred while
   establishing a connection to SQL Server. The server was not found or
  was not accessible. Verify that the instance name is correct and that
  SQL Server is configured to allow remote connections. (provider: SQL
  Network Interfaces, error: 26 - Error Locating Server/Instance
  Specified)[SqlException (0x80131904):    >System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
  owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
  allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
  userOptions, DbConnectionInternal& connection) +350

  System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
  owningObject, TaskCompletionSource1 retry, DbConnectionOptions
  userOptions, DbConnectionInternal& connection) +156

  System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
  owningConnection, TaskCompletionSource1 retry, DbConnectionOptions
  userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
  connection) +268

  System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
  outerConnection, DbConnectionFactory connectionFactory,
  TaskCompletionSource1 retry, DbConnectionOptions userOptions) +314

  System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
  retry) +204

  System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1
  retry) +428

  System.Data.SqlClient.SqlConnection.OpenAsync(CancellationToken
  cancellationToken) +572

  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.SqlServer.<<ExecuteAsync>b__3>d__6.MoveNext() +292
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.SqlServer.<ExecuteAsyncImplementation>d__91.MoveNext()
  +503    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.Core.EntityClient.d__8.MoveNext() +924

[EntityException: The underlying provider failed on Open.]

  System.Data.Entity.Core.EntityClient.d__8.MoveNext() +1255
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.Core.Objects.d__9.MoveNext()
  +514    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.Core.Objects.d__3d1.MoveNext()
  +312    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.SqlServer.<ExecuteAsyncImplementation>d__91.MoveNext()
  +579    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    System.Data.Entity.Utilities.CultureAwaiter1.GetResult()
  +48    System.Data.Entity.Core.Objects.<GetResultsAsync>d__e.MoveNext() +734
  System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    System.Data.Entity.Utilities.CultureAwaiter1.GetResult()
  +48    System.Data.Entity.Internal.d__0.MoveNext() +332    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62

  System.Data.Entity.Infrastructure.d__251.MoveNext()
  +371    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    Microsoft.AspNet.Identity.CultureAwaiter1.GetResult()
  +48    Microsoft.AspNet.Identity.d__13.MoveNext() +438    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    Microsoft.AspNet.Identity.CultureAwaiter1.GetResult()
  +48    Microsoft.AspNet.Identity.<RoleExistsAsync>d__d.MoveNext() +403    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +31

  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task) +62    Microsoft.AspNet.Identity.AsyncHelper.RunSync(Func1
  func) +232    ERPLite.Startup.CreateRolesandUsers() in
  C:\Users\trss\source\repos\ERP\ERP\Startup.cs:36

  ERPLite.Startup.Configuration(IAppBuilder app) in
  C:\Users\trss\source\repos\ERP\ERP\Startup.cs:22

[TargetInvocationException: Exception has been thrown by the target of
  an invocation.]    System.RuntimeMethodHandle.InvokeMethod(Object
  target, Object[] arguments, Signature sig, Boolean constructor) +0

  System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
  Object[] parameters, Object[] arguments) +128

  System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
  invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  +146    Owin.Loader.<>c__DisplayClass12.b__b(IAppBuilder builder) +93

  Owin.Loader.<>c__DisplayClass1.b__0(IAppBuilder
  builder) +209

  Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1
  startup) +842

  Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 startup) +51
  Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint()
  +101    System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
  +136    Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication
  context) +162

  System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
  appContext, HttpContext context, MethodInfo[] handlers) +583

  System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
  MethodInfo[] handlers, IntPtr appContext, HttpContext context) +169

  System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
  appContext, HttpContext context) +396

  System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
  appContext) +333

[HttpException (0x80004005): Exception has been thrown by the target
  of an invocation.]

  System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525

  System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
  +124    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
  wr, HttpContext context) +700


问:
Email clients for Dynamics AX
I am wondering how the process of sending email is working between Dynamics Ax client and Email client that is set for the server as default email client.

First of all can Dynamics Ax use alternative email clients (not outlook) for sending emails and second of all is Dynamics Ax sending whole configuration to the client, or client has to be configured by itself.

Right now I am experiencing unknown error while trying to send email using Windows Live Mail.

答:
Using SysOutgoingEmailTable and SysOutgoingEmailData you can send email to recipient of any domain and attach files too.

you have following fields:

```<code>outgoingEmailTable.EmailItemId
outgoingEmailTable.IsSystemEmail
outgoingEmailTable.Sender
outgoingEmailTable.SenderName
outgoingEmailTable.Recipient
outgoingEmailTable.Subject
outgoingEmailTable.Priority
outgoingEmailTable.WithRetries
outgoingEmailTable.RetryNum
outgoingEmailTable.UserId
outgoingEmailTable.Status
outgoingEmailTable.Message
outgoingEmailTable.TemplateId
outgoingEmailTable.LatestStatusChangeDateTime

outgoingEmailData.EmailItemId
outgoingEmailData.FileName
outgoingEmailData.EmailDataType
outgoingEmailData.FileExtension
</code>```

insert respective email detail in these tables and you are good to go. Further if it gives permission error do add permission set with
   CodeAccessPermission::assertMultiple .

Title: Email clients for Dynamics AX

Body:
Using SysOutgoingEmailTable and SysOutgoingEmailData you can send email to recipient of any domain and attach files too.

you have following fields:

outgoingEmailTable.EmailItemId
outgoingEmailTable.IsSystemEmail
outgoingEmailTable.Sender
outgoingEmailTable.SenderName
outgoingEmailTable.Recipient
outgoingEmailTable.Subject
outgoingEmailTable.Priority
outgoingEmailTable.WithRetries
outgoingEmailTable.RetryNum
outgoingEmailTable.UserId
outgoingEmailTable.Status
outgoingEmailTable.Message
outgoingEmailTable.TemplateId
outgoingEmailTable.LatestStatusChangeDateTime

outgoingEmailData.EmailItemId
outgoingEmailData.FileName
outgoingEmailData.EmailDataType
outgoingEmailData.FileExtension

insert respective email detail in these tables and you are good to go. Further if it gives permission error do add permission set with
   CodeAccessPermission::assertMultiple .


问:
Tune Spark, set executors and memory driver for reading large csv file
I am wondering how to choose the best settings to run tune me Spark Job.
Basically I am just reading a big csv file into a DataFrame and count some string occurrences.

The input file is over 500 GB. The spark job seems too slow..

terminal Progress Bar:

```<code>[Stage1:=======>                      (4174 + 50) / 18500]
</code>```

NumberCompletedTasks: (4174) takes around one hour.

NumberActiveTasks: (50), I believe I can control with setting.
--conf spark.dynamicAllocation.maxExecutors=50  (tried with different values).

TotalNumberOfTasks: (18500), why is this fixed? what does it mean, is it only related to file size?
Since I am reading a csv just with little logic, how can I optimize the Spark Job?

I also tried changing :

```<code> --executor-memory 10g
 --driver-memory 12g
</code>```

答: The Number of tasks depends upon number of partitions of your source RDD, in your case you are reading from HDFS, the block size decides number of partitions thus the number of tasks, it won't be based on number of executors, if you want to increase/decrease number of tasks you need to alter partitions, in your case you need to override HDFS configurations  min/maxSplit size when reading, for an existing RDD we can use repartion/coalesce to do the same.</p>

Body:
I am wondering how to choose the best settings to run tune me Spark Job.
Basically I am just reading a big csv file into a DataFrame and count some string occurrences.

The input file is over 500 GB. The spark job seems too slow..

terminal Progress Bar:

[Stage1:=======>                      (4174 + 50) / 18500]

NumberCompletedTasks: (4174) takes around one hour.

NumberActiveTasks: (50), I believe I can control with setting.
--conf spark.dynamicAllocation.maxExecutors=50  (tried with different values).

TotalNumberOfTasks: (18500), why is this fixed? what does it mean, is it only related to file size?
Since I am reading a csv just with little logic, how can I optimize the Spark Job?

I also tried changing :

 --executor-memory 10g
 --driver-memory 12g


问:
question on tomcat for serving of webapps and web-inf

There is a project deployed in Tomcat.

The web-app of course in is webapps of tomcat and the structure is as follows:

```<code>tomcat-home
|--webapps
       |
        -MyProject
                 |
                  -WEB-INF
                  -startingPoint.js
                  -client
                  -other dirs etc
</code>```

Now startingPoint.js is a javascript file that essentially loads an applet in the browser and is similar to this:

```<code>document.write('<OBJECT ');
document.write('  codebase = "jre.exe" WIDTH = "100%" HEIGHT = "100%" MAYSCRIPT > ');
document.write('  <PARAM NAME = CODE VALUE = "com/AnApplet.class" > ');
document.write('  <PARAM NAME = CODEBASE VALUE = "/MyProject/client/classes" >');
document.write('  <PARAM NAME = ARCHIVE VALUE = "/MyProject/client/lib/Appletclient.jar"> ');
document.write('  <PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.6"> ');
document.write('  <PARAM NAME = "MAYSCRIPT" VALUE="true"> ');
etc.
</code>```

If I write in the IE url bar the url:

http://ip:port/MyProject  (tomcat is running of course) the applet is loaded in my browser but I can not understand how.

I mean from web.xml I can not see something that would serve the javascript file.

If a js file is in the roor directory of my project, does it get automatically served?

I feel I am missing something here.

Could someone please advice, what is it here I should be looking for?

Thanks

答:
Hi
Another approach could be,
You just write a  index.jsp/ index.html.
Include your js in the file.

Call .js on

```<code><body onload=foo();>
</code>```

ContentLicense: CC BY-SA 2.5

Body:
There is a project deployed in Tomcat.

The web-app of course in is webapps of tomcat and the structure is as follows:

tomcat-home
|--webapps
       |
        -MyProject
                 |
                  -WEB-INF
                  -startingPoint.js
                  -client
                  -other dirs etc

Now startingPoint.js is a javascript file that essentially loads an applet in the browser and is similar to this:

document.write('<OBJECT ');
document.write('  codebase = "jre.exe" WIDTH = "100%" HEIGHT = "100%" MAYSCRIPT > ');
document.write('  <PARAM NAME = CODE VALUE = "com/AnApplet.class" > ');
document.write('  <PARAM NAME = CODEBASE VALUE = "/MyProject/client/classes" >');
document.write('  <PARAM NAME = ARCHIVE VALUE = "/MyProject/client/lib/Appletclient.jar"> ');
document.write('  <PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.6"> ');
document.write('  <PARAM NAME = "MAYSCRIPT" VALUE="true"> ');
etc.

If I write in the IE url bar the url:

http://ip:port/MyProject  (tomcat is running of course) the applet is loaded in my browser but I can not understand how.

I mean from web.xml I can not see something that would serve the javascript file.

If a js file is in the roor directory of my project, does it get automatically served?

I feel I am missing something here.

Could someone please advice, what is it here I should be looking for?

Thanks

Body:
Hi
Another approach could be,
You just write a  index.jsp/ index.html.
Include your js in the file.

Call .js on

<body onload=foo();>


问:
set dropdown list option with ellipses
I want to add ellipsis in the dropdown list options if I click the ellipsis able to see the full option values

for example, dropdown list looking like this

```<code><select id ="id">
        <option>One - A long text need to be cut off with ellipsis</option>
        <option>Two - A long text need to be cut off with ellipsis</option>
</select>
</code>```

I am expecting the output like as follows

One - A long option....
Two - A long option....

when clicking the ellipses able to see the full option values like
One - A long text need to be cut off with ellipsis

Please see the code which I done so far

```<code><!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<style>
select {
    width:200px;
}
</style>
<script>
$(document).ready(function() {
var maxLength = 20;
    $('#example > option').text(function(i, text) {
    if (text.length > maxLength) {
        return text.substr(0, maxLength) + '...';
        }
    });
});
</script>
</head>
<body>
<select name="example" id="example">
    <option value="">John Smith,1019 Your Company PO Box 7169 Poole BH15 9EL</option>
    <option value="">91 Western Road,Brighton PO Box 7169 East Sussex England BN1 2NWL</option>
    <option value="">John Smith,1019 Your Company PO Box 7169 Poole BH15 9EL</option>
</select>
</body>
</html>
</code>```

Please help me to get the expected result as above

答:
This is code for setting title display Option text</p>

```<code>$(function(){
              $("select option").attr( "title", "" );
              $("select option").each(function(i){
                this.title = this.text;

              })
            });
            $("select").tooltip({
                left:25
            });
</code>```

Title: set dropdown list option with ellipses

Body:
I want to add ellipsis in the dropdown list options if I click the ellipsis able to see the full option values

for example, dropdown list looking like this

<select id ="id">
        <option>One - A long text need to be cut off with ellipsis</option>
        <option>Two - A long text need to be cut off with ellipsis</option>
</select>

I am expecting the output like as follows

One - A long option....
Two - A long option....

when clicking the ellipses able to see the full option values like
One - A long text need to be cut off with ellipsis

Please see the code which I done so far

<!DOCTYPE html>

<select name="example" id="example">
    <option value="">John Smith,1019 Your Company PO Box 7169 Poole BH15 9EL</option>
    <option value="">91 Western Road,Brighton PO Box 7169 East Sussex England BN1 2NWL</option>
    <option value="">John Smith,1019 Your Company PO Box 7169 Poole BH15 9EL</option>
</select>

Please help me to get the expected result as above

Body:
This is code for setting title display Option text

$(function(){
              $("select option").attr( "title", "" );
              $("select option").each(function(i){
                this.title = this.text;

              })
            });
            $("select").tooltip({
                left:25
            });


问:
Android Studio - Failed to notify project evaluation listener error
Following is the build.gradle code in Android Studio

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.sg.blahblah"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    lintOptions {
        checkReleaseBuilds true
        abortOnError false
        xmlReport true
        htmlReport true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            lintOptions {
                disable 'MissingTranslation'
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.google.android.apps.dashclock:dashclock-api:+'
    compile 'com.roughike:bottom-bar:1.4.0.1'
    compile 'com.diogobernardino:williamchart:2.2'
}
</code>```

I am getting the below error:
Error:A problem occurred configuring project ':app'.

Failed to notify project evaluation listener.
  com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V

Can anyone please help?

Following is the Instant Run screenshot

答:
Usually it depends on Instant run or Gradle, but I tried both variants and nothing helped me. Then I looked through idea.log and saw this error

```<code>Caused by: java.lang.RuntimeException: A conflict was found between the
following modules:
 - com.android.support:support-core-utils:25.3.1
 - com.android.support:support-core-utils:27.0.1
</code>```

I really don't know why this error is not shown in Gradle Console or Event Log tab. Then I fixed it by adding some code to the end of android{} block.

```<code>configurations.all {
    resolutionStrategy {
        failOnVersionConflict()
        eachDependency { DependencyResolveDetails details ->
            if (details.requested.name == 'support-core-utils') {
                details.useVersion '25.3.1'//Or you can use 27.0.1 if it does not conflict with your other dependencies
            }
    }
}
</code>```

Body:
Following is the build.gradle code in Android Studio

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.sg.blahblah"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

    lintOptions {
        checkReleaseBuilds true
        abortOnError false
        xmlReport true
        htmlReport true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            lintOptions {
                disable 'MissingTranslation'
            }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.google.android.apps.dashclock:dashclock-api:+'
    compile 'com.roughike:bottom-bar:1.4.0.1'
    compile 'com.diogobernardino:williamchart:2.2'
}

I am getting the below error:
Error:A problem occurred configuring project ':app'.

Failed to notify project evaluation listener.
  com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V

Can anyone please help?

Following is the Instant Run screenshot

Body:
Usually it depends on Instant run or Gradle, but I tried both variants and nothing helped me. Then I looked through idea.log and saw this error

Caused by: java.lang.RuntimeException: A conflict was found between the
following modules:
 - com.android.support:support-core-utils:25.3.1
 - com.android.support:support-core-utils:27.0.1

I really don't know why this error is not shown in Gradle Console or Event Log tab. Then I fixed it by adding some code to the end of android{} block.

configurations.all {
    resolutionStrategy {
        failOnVersionConflict()
        eachDependency { DependencyResolveDetails details ->
            if (details.requested.name == 'support-core-utils') {
                details.useVersion '25.3.1'//Or you can use 27.0.1 if it does not conflict with your other dependencies
            }
    }
}


问:
How do I run Python code from Sublime Text 2?
I want to set up a complete Python IDE in Sublime Text 2.

I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?

答:
In python v3.x you should go to : Tools->Build System->New Build System.

Then, it pop up the untitled.sublime-build window in sublime text editor.Enter setting as:

```<code>{

    "cmd": ["path_to_the_python.exe","-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}
</code>```

To see the path, Type following in terminal as:

```<code>python
>>> import sys
>>>print(sys.executable)
</code>```

You can make more than one Build System but it should default save inside Packages of Sublime text with .sublime-build extension.

Then, select the new Build System  and press cltr+b or other based on your os.

Body:
In python v3.x you should go to : Tools->Build System->New Build System.

Then, it pop up the untitled.sublime-build window in sublime text editor.Enter setting as:

{

    "cmd": ["path_to_the_python.exe","-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

To see the path, Type following in terminal as:

python
>>> import sys
>>>print(sys.executable)

You can make more than one Build System but it should default save inside Packages of Sublime text with .sublime-build extension.

Then, select the new Build System  and press cltr+b or other based on your os.


问:
How-to do regex in macros?
```<code>{% nilable = /\:\:Nil|\?$/.match(type) %}
</code>```

It doesn't seem to work: undefined macro method 'RegexLiteral#match'.

答:
Macros::StringLiteral has =~ instance:

```<code>{% type = "Module::Nil" %}
{% p type =~ /\:\:Nil|\?$/ %} #=> true

{% type = "Module::Null" %}
{% p type =~ /\:\:Nil|\?$/ %} #=> false
</code>```

Title: How-to do regex in macros?

Body:
{% nilable = /\:\:Nil|\?$/.match(type) %}

It doesn't seem to work: undefined macro method 'RegexLiteral#match'.

Body:
Macros::StringLiteral has =~ instance:

{% type = "Module::Nil" %}
{% p type =~ /\:\:Nil|\?$/ %} #=> true

{% type = "Module::Null" %}
{% p type =~ /\:\:Nil|\?$/ %} #=> false


问:
Error: Could not find or load main class ... in Spring Boot 1.5.9 version but not in 1.4.7

I was trying to generate a starting spring boot project from https://start.spring.io/

When I use Spring Boot 1.5.9 version to generate the project I am getting the following

```<code>Error: Could not find or load main class com.example.demo120417.Demo120417Application
</code>```

However; changing the version to Spring Boot 1.4.7 loads and runs the main class with no error.

I have actuator, security, thymeleaf, devtools, h2 in the dependency.

```<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>com.example</groupId>
<artifactId>demo120417</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>demo120417</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.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-actuator</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-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</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.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
</project>
</code>```

What could be the root cause for this? I spent almost 1 day trying to figure out if I had issue with build path. Usually having red exclamation mark on the project points me to the library issue.

答:
change to version 1.5.8 instead of 1.5.9
it works for me</p>

Body:
I was trying to generate a starting spring boot project from https://start.spring.io/

When I use Spring Boot 1.5.9 version to generate the project I am getting the following

Error: Could not find or load main class com.example.demo120417.Demo120417Application

However; changing the version to Spring Boot 1.4.7 loads and runs the main class with no error.

I have actuator, security, thymeleaf, devtools, h2 in the dependency.

<?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>com.example</groupId>
<artifactId>demo120417</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>demo120417</name>
<description>Demo project for Spring Boot</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.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-actuator</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-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</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.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
</project>

What could be the root cause for this? I spent almost 1 day trying to figure out if I had issue with build path. Usually having red exclamation mark on the project points me to the library issue.


问:
JENKINS: ERROR when I try to use an older JDK for a specific maven project
I am using the Jenkins version 2.73-1.1 on a CentOS Linux release 7.3.1611 server.

There are 3 different versions of JDK on the server:

```<code>[root @ jenkins java] # ll
total 12
lrwxrwxrwx. 1 root root 16 27 Apr 16.25 default -> / usr / java / latest
drwxr-xr-x. 8 root root 4096 27 Mar 2013 jdk1.6.0_45
drwxr-xr-x. Root root 4096 11 Apr 2015 jdk1.7.0_80
drwxr-xr-x. 9 root root 4096 27 Apr 16.25 jdk1.8.0_131
lrwxrwxrwx. 1 root root 22 27 apr 16.25 latest -> /usr/java/jdk1.8.0_131
</code>```

As shown in the pictures below, Jenkins is using the jdk1.8.0_131 version and in my project I specified to use JDK7.

Jenkins setup Image 1

Jenkins setup Image 2

When I try to compile my project (mvn clean deploy), the build fails and I see this ERROR in log:

[Vodafone] $ /usr/java/jdk1.7.0_80/bin/java -cp
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar
  org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache-maven-3.0.4
  /var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar
  46349 <===[JENKINS REMOTING CAPACITY]===>channel started ERROR:
  ================================================================================ ERROR: Invalid project setup: jenkins/security/MasterToSlaveCallable :
  Unsupported major.minor version 52.0 ERROR:
  [JENKINS-18403][JENKINS-28294] JDK 'JAVA7' not supported to run Maven
  projects. ERROR: Maven projects have to be launched with a Java
  version greater or equal to the minimum version required by the
  master. ERROR: Use the Maven JDK Toolchains (plugin) to build your
  maven project with an older JDK. ERROR: Retrying with slave Java and
  setting compile/test properties to point to /usr/java/jdk1.7.0_80.
  ERROR:
  ================================================================================ Established TCP socket on 38129 [Vodafone] $
  /usr/java/jdk1.8.0_131/jre/bin/java -cp
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar
  org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache-maven-3.0.4
  /var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar
  38129 <===[JENKINS REMOTING CAPACITY]===>channel started

Why Jenkins doesn't use jdk 7?

答:
As it is documented on the maven project plugin of Jenkins home page:

Jenkins >= 2.54 requires Java 8 thus Maven jobs must be launched with Java >= 8

Luckily the best workaround is just mentioned in your stack trace:

... Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK...

In order to compile your project using java 7 and launch a successful Jenkins job using the current Jenkins version, I would recommend you use toolchains plugin in 2 simple steps:

Add toolchains.xml file to your .m2 directory both on developers system and Jenkins server

```<code> <toolchains>
   <toolchain>
     <type>jdk</type>
     <provides>
       <version>1.7</version>
       <vendor>openjdk</vendor>
     </provides>
     <configuration>
       <jdkHome>/usr/lib/jvm/java-7-openjdk-amd64</jdkHome>
     </configuration>
   </toolchain>
   <toolchain>
     <type>jdk</type>
     <provides>
       <version>1.8</version>
       <vendor>openjdk</vendor>
     </provides>
     <configuration>
       <jdkHome>/usr/lib/jvm/java-8-openjdk-amd64</jdkHome>
     </configuration>
   </toolchain>
   [...]
 </toolchains>
</code>```

Add toolchain plugin to your project pom file

```<code> <project>
   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-toolchains-plugin</artifactId>
         <version>1.1</version>
         <executions>
           <execution>
             <goals>
               <goal>toolchain</goal>
             </goals>
             </execution>
           </executions>
           <configuration>
             <toolchains>
               <jdk>
                 <version>1.7</version>
                 <vendor>openjdk</vendor>
               </jdk>
             </toolchains>
           </configuration>
       </plugin>
     </plugins>
   </build>
 </project>
</code>```

Finally, config your Jenkins job to use jdk 8, the toolchain will take care of compiling your project with jdk 7.

Body:
I am using the Jenkins version 2.73-1.1 on a CentOS Linux release 7.3.1611 server.

There are 3 different versions of JDK on the server:

[root @ jenkins java] # ll
total 12
lrwxrwxrwx. 1 root root 16 27 Apr 16.25 default -> / usr / java / latest
drwxr-xr-x. 8 root root 4096 27 Mar 2013 jdk1.6.0_45
drwxr-xr-x. Root root 4096 11 Apr 2015 jdk1.7.0_80
drwxr-xr-x. 9 root root 4096 27 Apr 16.25 jdk1.8.0_131
lrwxrwxrwx. 1 root root 22 27 apr 16.25 latest -> /usr/java/jdk1.8.0_131

As shown in the pictures below, Jenkins is using the jdk1.8.0_131 version and in my project I specified to use JDK7.

Jenkins setup Image 1

Jenkins setup Image 2

When I try to compile my project (mvn clean deploy), the build fails and I see this ERROR in log:

[Vodafone] $ /usr/java/jdk1.7.0_80/bin/java -cp
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar
  org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache-maven-3.0.4
  /var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar
  46349 <===[JENKINS REMOTING CAPACITY]===>channel started ERROR:
  ================================================================================ ERROR: Invalid project setup: jenkins/security/MasterToSlaveCallable :
  Unsupported major.minor version 52.0 ERROR:
  [JENKINS-18403][JENKINS-28294] JDK 'JAVA7' not supported to run Maven
  projects. ERROR: Maven projects have to be launched with a Java
  version greater or equal to the minimum version required by the
  master. ERROR: Use the Maven JDK Toolchains (plugin) to build your
  maven project with an older JDK. ERROR: Retrying with slave Java and
  setting compile/test properties to point to /usr/java/jdk1.7.0_80.
  ERROR:
  ================================================================================ Established TCP socket on 38129 [Vodafone] $
  /usr/java/jdk1.8.0_131/jre/bin/java -cp
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.11.jar:/opt/apache-maven-3.0.4/boot/plexus-classworlds-2.4.jar
  org.jvnet.hudson.maven3.agent.Maven3Main /opt/apache-maven-3.0.4
  /var/cache/jenkins/war/WEB-INF/lib/remoting-3.10.jar
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.11.jar
  /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.11.jar
  38129 <===[JENKINS REMOTING CAPACITY]===>channel started

Why Jenkins doesn't use jdk 7?

Body:
As it is documented on the maven project plugin of Jenkins home page:

Jenkins >= 2.54 requires Java 8 thus Maven jobs must be launched with Java >= 8

Luckily the best workaround is just mentioned in your stack trace:

... Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK...

In order to compile your project using java 7 and launch a successful Jenkins job using the current Jenkins version, I would recommend you use toolchains plugin in 2 simple steps:

Add toolchains.xml file to your .m2 directory both on developers system and Jenkins server

 <toolchains>
   <toolchain>
     <type>jdk</type>
     <provides>
       <version>1.7</version>
       <vendor>openjdk</vendor>
     </provides>
     <configuration>
       <jdkHome>/usr/lib/jvm/java-7-openjdk-amd64</jdkHome>
     </configuration>
   </toolchain>
   <toolchain>
     <type>jdk</type>
     <provides>
       <version>1.8</version>
       <vendor>openjdk</vendor>
     </provides>
     <configuration>
       <jdkHome>/usr/lib/jvm/java-8-openjdk-amd64</jdkHome>
     </configuration>
   </toolchain>
   [...]
 </toolchains>

Add toolchain plugin to your project pom file

 <project>
   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-toolchains-plugin</artifactId>
         <version>1.1</version>
         <executions>
           <execution>
             <goals>
               <goal>toolchain</goal>
             </goals>
             </execution>
           </executions>
           <configuration>
             <toolchains>
               <jdk>
                 <version>1.7</version>
                 <vendor>openjdk</vendor>
               </jdk>
             </toolchains>
           </configuration>
       </plugin>
     </plugins>
   </build>
 </project>

Finally, config your Jenkins job to use jdk 8, the toolchain will take care of compiling your project with jdk 7.