问:
How do I set up a GCP App Engine instance with CORS?
I've set up two different GCP App Engine apps. One is an express server (let's call it foo) with the following app.yaml:

```<code>runtime: nodejs10
handlers:
- url: /tasks
  static_dir: /tasks
  http_headers:
    Access-Control-Allow-Origin: https://bar.appspot.com/
  secure: always
</code>```

From my bar app, I'm trying to do a fetch call:

```<code>const response = await fetch('https://foo.appspot.com/tasks');
</code>```

Every time I try this, however, Chrome blocks my request with the 'has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.' error. I've also tried just replacing the URL in the http_header with '*' to no avail. Why is this? What am I missing?

Edit: After some more digging, I'm finding that the headers being returned from foo don't even include the Access-Control-Allow-Origin header at all.

Edit 2: I finally bypassed this issue by just using the npm cors package: https://www.npmjs.com/package/cors

答:
As of May 2020, I had the same issue, css files being blocked by CORS policy on browser, served by Google cloud storage.

And as addressed in this Gcloud wiki page: https://cloud.google.com/storage/docs/configuring-cors#configure-cors-bucket

It worked for me, by setting the CORS on the G storage bucket.

And don't need the handlers stuff config in app.yaml, and I'm not a big fan of YAML btw...

Body:
I've set up two different GCP App Engine apps. One is an express server (let's call it foo) with the following app.yaml:

runtime: nodejs10
handlers:
- url: /tasks
  static_dir: /tasks
  http_headers:
    Access-Control-Allow-Origin: https://bar.appspot.com/
  secure: always

From my bar app, I'm trying to do a fetch call:

const response = await fetch('https://foo.appspot.com/tasks');

Every time I try this, however, Chrome blocks my request with the 'has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.' error. I've also tried just replacing the URL in the http_header with '*' to no avail. Why is this? What am I missing?

Edit: After some more digging, I'm finding that the headers being returned from foo don't even include the Access-Control-Allow-Origin header at all.

Edit 2: I finally bypassed this issue by just using the npm cors package: https://www.npmjs.com/package/cors


来源: stackexchange

问:
"python -m pip install --upgrade pip" Exception error
In windows 10, I am running the terminal as an administrator,

It is giving an exception error.

I am trying to upgrade pip but it is giving an error:

```<code>python -m pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.3.1
    Uninstalling pip-19.3.1:
      Successfully uninstalled pip-19.3.1
  Rolling back uninstall of pip
  Moving to c:\users\user1\appdata\roaming\python\python38\scripts\
   from C:\Users\user1\AppData\Roaming\Python\Python38\~cripts
  Moving to c:\users\user1\appdata\roaming\python\python38\site-packages\pip-19.3.1.dist-info\
   from C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\~ip-19.3.1.dist-info
  Moving to c:\users\user1\appdata\roaming\python\python38\site-packages\pip\
   from C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\~ip
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\cli\base_command.py", line 153, in _main
    status = self.run(options, args)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\commands\install.py", line 446, in run
    installed = install_given_reqs(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\req\__init__.py", line 58, in install_given_reqs
    requirement.install(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\req\req_install.py", line 858, in install
    self.move_wheel_files(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\req\req_install.py", line 487, in move_wheel_files
    wheel.move_wheel_files(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\wheel.py", line 594, in move_wheel_files
    generated_console_scripts = maker.make_multiple(scripts_to_generate)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 402, in make_multiple
    filenames.extend(self.make(specification, options))
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\wheel.py", line 330, in make
    return super(PipScriptMaker, self).make(specification, options)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 391, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 295, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 231, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 370, in _get_launcher
    result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
WARNING: You are using pip version 19.3.1; however, version 20.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
</code>```

What should I do to upgrade pip?
Thanks

答:
Try this :

```<code>easy_install -U pip
</code>```

If the above command doesn't work, try the following :

```<code>python -m pip install -U --force-reinstall pip
</code>```

ContentLicense: CC BY-SA 4.0

Body:
In windows 10, I am running the terminal as an administrator,

It is giving an exception error.

I am trying to upgrade pip but it is giving an error:

python -m pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.3.1
    Uninstalling pip-19.3.1:
      Successfully uninstalled pip-19.3.1
  Rolling back uninstall of pip
  Moving to c:\users\user1\appdata\roaming\python\python38\scripts\
   from C:\Users\user1\AppData\Roaming\Python\Python38\~cripts
  Moving to c:\users\user1\appdata\roaming\python\python38\site-packages\pip-19.3.1.dist-info\
   from C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\~ip-19.3.1.dist-info
  Moving to c:\users\user1\appdata\roaming\python\python38\site-packages\pip\
   from C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\~ip
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\cli\base_command.py", line 153, in _main
    status = self.run(options, args)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\commands\install.py", line 446, in run
    installed = install_given_reqs(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\req\__init__.py", line 58, in install_given_reqs
    requirement.install(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\req\req_install.py", line 858, in install
    self.move_wheel_files(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\req\req_install.py", line 487, in move_wheel_files
    wheel.move_wheel_files(
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\wheel.py", line 594, in move_wheel_files
    generated_console_scripts = maker.make_multiple(scripts_to_generate)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 402, in make_multiple
    filenames.extend(self.make(specification, options))
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_internal\wheel.py", line 330, in make
    return super(PipScriptMaker, self).make(specification, options)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 391, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 295, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 231, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\user1\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\distlib\scripts.py", line 370, in _get_launcher
    result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'
WARNING: You are using pip version 19.3.1; however, version 20.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

What should I do to upgrade pip?
Thanks

Body:
Try this :

easy_install -U pip

If the above command doesn't work, try the following :

python -m pip install -U --force-reinstall pip


问:
is there somebody that can fix this if statement
```<code>static void Main(string[] args)
{
    string name01;
    string name02;

    Console.WriteLine("Welcome to Choice RPG! <press enter to start your adventure>");
    Console.ReadKey();
    Console.WriteLine("Enter your Adventurers name! <press enter to continue>");
    name01 = Convert.ToString(Console.ReadLine());
    Console.WriteLine(name01 + "! come on, you can think of a better name than that can't you? <press enter to continue>");
    Console.ReadKey();
    Console.WriteLine("Enter your Adventurers name! <press enter to continue>");
    name02 = Convert.ToString(Console.ReadLine());

    if (name02 == name01)
    {
        Console.WriteLine("Wow, i guess you really like that name huh, fine.");
    }
    else
    {
        Console.WriteLine("Now thats more like it!");
    }
}
</code>```

This is my first project with programming in general. I am making an RPG game in which you choose your adventure and this is for the user's ingame name.

Everything works up until the if statement (after that the cmd just closes). If anyone has any ideas to fix it please tell me.

答:
Code looks OK to me, try adding:

```<code>Console.WriteLine("Press <ENTER> to exit");
Console.Readline();
</code>```

at the end to see if the message you want to show, actually shows before the application exits and closes. My guess is you are running in Visual Studio, and the message prints, but then the execution window closes so fast you don't see it.

Body:
static void Main(string[] args)
{
    string name01;
    string name02;

    Console.WriteLine("Welcome to Choice RPG! <press enter to start your adventure>");
    Console.ReadKey();
    Console.WriteLine("Enter your Adventurers name! <press enter to continue>");
    name01 = Convert.ToString(Console.ReadLine());
    Console.WriteLine(name01 + "! come on, you can think of a better name than that can't you? <press enter to continue>");
    Console.ReadKey();
    Console.WriteLine("Enter your Adventurers name! <press enter to continue>");
    name02 = Convert.ToString(Console.ReadLine());

    if (name02 == name01)
    {
        Console.WriteLine("Wow, i guess you really like that name huh, fine.");
    }
    else
    {
        Console.WriteLine("Now thats more like it!");
    }
}

This is my first project with programming in general. I am making an RPG game in which you choose your adventure and this is for the user's ingame name.

Everything works up until the if statement (after that the cmd just closes). If anyone has any ideas to fix it please tell me.

Body:
Code looks OK to me, try adding:

Console.WriteLine("Press <ENTER> to exit");
Console.Readline();

at the end to see if the message you want to show, actually shows before the application exits and closes. My guess is you are running in Visual Studio, and the message prints, but then the execution window closes so fast you don't see it.


问:
Isolated Azure Kubernetes Service (AKS) SSL Error
I deployed a helm chart onto an isolated server and in the self-signed certificate HTTPS post it does to the kube-api it is failing w/ this error:

curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to kubernetes.default.svc:443

Anyone seen it before? This is the “POST”:

```<code>echo "Creating a secret for the certificate and keys"
 STATUS=$(curl -ik \
            -o ${TMP_DIR}/output \
            -w "%{http_code}" \
            -X POST \
            -H "Authorization: Bearer $TOKEN" \
            -H 'Accept: application/json' \
            -H 'Content-Type: application/json' \
            -d '{
            "kind": "Secret",
            "apiVersion": "v1",
            "metadata": {
              "name": "spark-webhook-certs",
              "namespace": "'"$NAMESPACE"'"
            },
            "data": {
              "ca-cert.pem": "'"$ca_cert"'",
              "ca-key.pem": "'"$ca_key"'",
              "server-cert.pem": "'"$server_cert"'",
              "server-key.pem": "'"$server_key"'"
            }
           }' \
           https://kubernetes.default.svc/api/v1/namespaces/${NAMESPACE}/secrets

</code>```

The error is occuring due to a self signed certificate whose .sh is being invoked by a docker image command here: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/master/hack/gencerts.sh

I know it's not getting to the end of this because it's failing to make the secret it's trying to post. Where do y'all think I should look to start troubleshooting? I've posted additional info here including screen shots: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/issues/926

答:
I would try to update the contents of gencerts.sh to get some more context on the error:

Add the -v or --verbose option to the curl command.

Use strace to invoke the curl command

Both of those options will send more outputs to stderr so you should be able to inspect in your log and get a better idea of the failure mode. Fair warning: strace will generate a lot of output.

Another source of information would be the kube-apiserver logs. You'll need to enable collection of master logs by adjusting the configuration of your cluster. You should expect every API request to be logged by kube-apiserver.

The first question here is whether the request is received by the control plane at all. To troubleshoot this, I would get a shell on a container inside the cluster and try to recreate the curl request that gencerts.sh is making. There is some information on accessing the cluster API without kubectl in the kubernetes docs.

Body:
I deployed a helm chart onto an isolated server and in the self-signed certificate HTTPS post it does to the kube-api it is failing w/ this error:

curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to kubernetes.default.svc:443

Anyone seen it before? This is the “POST”:

echo "Creating a secret for the certificate and keys"
 STATUS=$(curl -ik \
            -o ${TMP_DIR}/output \
            -w "%{http_code}" \
            -X POST \
            -H "Authorization: Bearer $TOKEN" \
            -H 'Accept: application/json' \
            -H 'Content-Type: application/json' \
            -d '{
            "kind": "Secret",
            "apiVersion": "v1",
            "metadata": {
              "name": "spark-webhook-certs",
              "namespace": "'"$NAMESPACE"'"
            },
            "data": {
              "ca-cert.pem": "'"$ca_cert"'",
              "ca-key.pem": "'"$ca_key"'",
              "server-cert.pem": "'"$server_cert"'",
              "server-key.pem": "'"$server_key"'"
            }
           }' \
           https://kubernetes.default.svc/api/v1/namespaces/${NAMESPACE}/secrets

The error is occuring due to a self signed certificate whose .sh is being invoked by a docker image command here: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/blob/master/hack/gencerts.sh

I know it's not getting to the end of this because it's failing to make the secret it's trying to post. Where do y'all think I should look to start troubleshooting? I've posted additional info here including screen shots: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator/issues/926


问:
How to improve a German text classification model in spaCy
I am working on a text classification project and using spacy for this. Right now I have an accuracy equal to almost 70% but that is not enough. I've been trying to improve the model for past two weeks, but no successful results so far. And here I am looking for an advice about what I should do or try. Any help would be highly appreciated!

So, here is what I do so far:

1) Preparing the data:

I have an unbalanced dataset of German news with 21 categories (like POLITICS, ECONOMY, SPORT, CELEBRITIES etc). In order to make categories equal I duplicate small classes. As a result I have 21 files with almost 700 000 lines of text. I then normalize this data using the following code:

```<code>import spacy
from charsplit import Splitter

POS = ['NOUN', 'VERB', 'PROPN', 'ADJ', 'NUM']  # allowed parts of speech

nlp_helper = spacy.load('de_core_news_sm')
splitter = Splitter()

def normalizer(texts):
    arr = []  # list of normalized texts (will be returned from the function as a result of normalization)

    docs = nlp_helper.pipe(texts)  # creating doc objects for multiple lines
    for doc in docs:  # iterating through each doc object
        text = []  # list of words in normalized text
        for token in doc:  # for each word in text
            token = token.lemma_.lower()

            if token not in stop_words and token.pos_ in POS:  # deleting stop words and some parts of speech
                if len(word) > 8 and token.pos_ == 'NOUN':  # only nouns can be splitted
                    _, word1, word2 = splitter.split_compound(word)[0]  # checking only the division with highest prob
                    word1 = word1.lower()
                    word2 = word2.lower()
                    if word1 in german and word2 in german:
                        text.append(word1)
                        text.append(word2)
                    elif word1[:-1] in german and word2 in german:  # word[:-1] - checking for 's' that joins two words
                        text.append(word1[:-1])
                        text.append(word2)
                    else:
                        text.append(word)
                else:
                    text.append(word)
        arr.append(re.sub(r'[.,;:?!"()-=_+*&^@/\']', ' ', ' '.join(text))) # delete punctuation
    return arr
</code>```

Some explanations to the above code:

POS - a list of allowed parts of speech. If the word I'm working with at the moment is a part of speech that is not in this list -> I delete it.

stop_words - just a list of words I delete.

splitter.split_compound(word)[0] - returns a tuple with the most likely division of the compound word (I use it to divide long German words into shorter and more widely used). Here is the link to the repository with this functionality.

To sum up: I find the lemma of the word, make it lower case, delete stop words and some parts of speech, divide compound words, delete punctuation. I then join all the words and return an array of normalized lines.

2) Training the model

I train my model using de_core_news_sm (to make it possible in the future to use this model not only for classification but also for normalization). Here is the code for training:

```<code>nlp = spacy.load('de_core_news_sm')

textcat = nlp.create_pipe('textcat', config={"exclusive_classes": False, "architecture": 'simple_cnn'})
nlp.add_pipe(textcat, last=True)
for category in categories:
    textcat.add_label(category)

pipe_exceptions = ["textcat"]
other_pipes = [pipe for pipe in nlp.pipe_names if pipe not in pipe_exceptions]

with nlp.disable_pipes(*other_pipes):
    optimizer = nlp.begin_training()

    for i in range(n_iter):
        shuffle(data)
        batches = spacy.util.minibatch(data)

        for batch in batches:
            texts, annotations = zip(*batch)
            nlp.update(texts, annotations, sgd=optimizer, drop=0.25)
</code>```

Some explanations to the above code:

data - list of lists, where each list includes a line of text and a dictionary with categories (just like in the docs)

'categories' - list of categories

'n_iter' - number of iterations for training

3) At the end I just save the model with to_disk method.

With the above code I managed to train a model with 70% accuracy. Here is a list of what I've tried so far to improve this score:

1) Using another architecture (ensemble) - didn't give any improvements

2) Training on non normalized data - the result was much worse

3) Using pretrained BERT model - could'n do it (here is my unanswered question about it)

4) Training de_core_news_md instead of de_core_news_sm - didn't give any improvements (tried it because according to the docs there could be an improvement thanks to the vectors (if I understood it correctly). Correct me if I'm wrong)

5) Training on data, normalized in a slightly different way (without lower casing and punctuation deletion) - didn't give any improvements

6) Changing dropout - didn't help

So right now I am a little stuck about what to do next. I would be very grateful for any hint or advice.

Thanks in advance for your help!

答:
The first thing I would suggest is increasing your batch size. After that your optimizer (Adam if possible) and learning rate for which I don't see the code here. You can finally try changing your dropout.

Also, if you are trying neural networks and plan on changing a lot, it would be better if you could switch to PyTorch or TensorFlow. In PyTorch, you will have HuggingFace library, which has BERT in-built in it.

Hope this helps you!

Body:
I am working on a text classification project and using spacy for this. Right now I have an accuracy equal to almost 70% but that is not enough. I've been trying to improve the model for past two weeks, but no successful results so far. And here I am looking for an advice about what I should do or try. Any help would be highly appreciated!

So, here is what I do so far:

1) Preparing the data:

I have an unbalanced dataset of German news with 21 categories (like POLITICS, ECONOMY, SPORT, CELEBRITIES etc). In order to make categories equal I duplicate small classes. As a result I have 21 files with almost 700 000 lines of text. I then normalize this data using the following code:

import spacy
from charsplit import Splitter

POS = ['NOUN', 'VERB', 'PROPN', 'ADJ', 'NUM']  # allowed parts of speech

nlp_helper = spacy.load('de_core_news_sm')
splitter = Splitter()

def normalizer(texts):
    arr = []  # list of normalized texts (will be returned from the function as a result of normalization)

    docs = nlp_helper.pipe(texts)  # creating doc objects for multiple lines
    for doc in docs:  # iterating through each doc object
        text = []  # list of words in normalized text
        for token in doc:  # for each word in text
            token = token.lemma_.lower()

            if token not in stop_words and token.pos_ in POS:  # deleting stop words and some parts of speech
                if len(word) > 8 and token.pos_ == 'NOUN':  # only nouns can be splitted
                    _, word1, word2 = splitter.split_compound(word)[0]  # checking only the division with highest prob
                    word1 = word1.lower()
                    word2 = word2.lower()
                    if word1 in german and word2 in german:
                        text.append(word1)
                        text.append(word2)
                    elif word1[:-1] in german and word2 in german:  # word[:-1] - checking for 's' that joins two words
                        text.append(word1[:-1])
                        text.append(word2)
                    else:
                        text.append(word)
                else:
                    text.append(word)
        arr.append(re.sub(r'[.,;:?!"()-=_+*&^@/\']', ' ', ' '.join(text))) # delete punctuation
    return arr

Some explanations to the above code:

POS - a list of allowed parts of speech. If the word I'm working with at the moment is a part of speech that is not in this list -> I delete it.

stop_words - just a list of words I delete.

splitter.split_compound(word)[0] - returns a tuple with the most likely division of the compound word (I use it to divide long German words into shorter and more widely used). Here is the link to the repository with this functionality.

To sum up: I find the lemma of the word, make it lower case, delete stop words and some parts of speech, divide compound words, delete punctuation. I then join all the words and return an array of normalized lines.

2) Training the model

I train my model using de_core_news_sm (to make it possible in the future to use this model not only for classification but also for normalization). Here is the code for training:

nlp = spacy.load('de_core_news_sm')

textcat = nlp.create_pipe('textcat', config={"exclusive_classes": False, "architecture": 'simple_cnn'})
nlp.add_pipe(textcat, last=True)
for category in categories:
    textcat.add_label(category)

pipe_exceptions = ["textcat"]
other_pipes = [pipe for pipe in nlp.pipe_names if pipe not in pipe_exceptions]

with nlp.disable_pipes(*other_pipes):
    optimizer = nlp.begin_training()

    for i in range(n_iter):
        shuffle(data)
        batches = spacy.util.minibatch(data)

        for batch in batches:
            texts, annotations = zip(*batch)
            nlp.update(texts, annotations, sgd=optimizer, drop=0.25)

Some explanations to the above code:

data - list of lists, where each list includes a line of text and a dictionary with categories (just like in the docs)

'categories' - list of categories

'n_iter' - number of iterations for training

3) At the end I just save the model with to_disk method.

With the above code I managed to train a model with 70% accuracy. Here is a list of what I've tried so far to improve this score:

1) Using another architecture (ensemble) - didn't give any improvements

2) Training on non normalized data - the result was much worse

3) Using pretrained BERT model - could'n do it (here is my unanswered question about it)

4) Training de_core_news_md instead of de_core_news_sm - didn't give any improvements (tried it because according to the docs there could be an improvement thanks to the vectors (if I understood it correctly). Correct me if I'm wrong)

5) Training on data, normalized in a slightly different way (without lower casing and punctuation deletion) - didn't give any improvements

6) Changing dropout - didn't help

So right now I am a little stuck about what to do next. I would be very grateful for any hint or advice.

Thanks in advance for your help!


问:
How to style google SwitchMaterial button on Android?
I have a material switch button like this:

```<code><com.google.android.material.switchmaterial.SwitchMaterial
                android:id="@+id/effectEnabled"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="3"
                style="@style/ButtonStyle2"
                android:checked="true"
                android:enabled="true" />
</code>```

here's the style:

```<code><style name="ButtonStyle2" parent="Base.Widget.AppCompat.Button">
        <!--<item name="android:fontFamily">sans-serif-light</item>-->
        <!--<item name="android:textStyle">bold</item>-->
        <item name="android:textColor">@color/colorPrimary</item>
        <item name="android:textSize">20sp</item>
        <item name="android:textAllCaps">false</item>
    </style>
</code>```

with these styles, the button gets broken and with a square background of grey color.

How can I style SwitchMaterial buttons? I just want to change the switch color

答:
You can use app:thumbTint and/or app:trackTint to change the switch colors.
For better results define a ColorStateList in res/color (ie: res/color/custom_thumb_selector.xml) to have differente colors based on if it is checked or not.
ie:

```<code><selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:color="@color/customChecked" />
    <item android:color="@color/customUnchecked" />
</selector>
</code>```

and then set it in your style:

```<code><style name="ButtonStyle2" parent="Widget.MaterialComponents.CompoundButton.Switch">
    <item name="thumbTint">@color/custom_thumb_selector</item>
</style>
</code>```

Note: Your custom style should inherit from Widget.MaterialComponents.CompoundButton.Switch

Body:
I have a material switch button like this:

<com.google.android.material.switchmaterial.SwitchMaterial
                android:id="@+id/effectEnabled"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="3"
                style="@style/ButtonStyle2"
                android:checked="true"
                android:enabled="true" />

here's the style:

with these styles, the button gets broken and with a square background of grey color.

How can I style SwitchMaterial buttons? I just want to change the switch color

Body:
You can use app:thumbTint and/or app:trackTint to change the switch colors.
For better results define a ColorStateList in res/color (ie: res/color/custom_thumb_selector.xml) to have differente colors based on if it is checked or not.
ie:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:color="@color/customChecked" />
    <item android:color="@color/customUnchecked" />
</selector>

and then set it in your style:

<style name="ButtonStyle2" parent="Widget.MaterialComponents.CompoundButton.Switch">
    <item name="thumbTint">@color/custom_thumb_selector</item>
</style>

Note: Your custom style should inherit from Widget.MaterialComponents.CompoundButton.Switch


问:
mmap call works on one system but fails with "Cannot allocate memory" on another. Both running same linux image, with plenty of memory
I'm trying to run some code I didn't write, that needs a large chunk (~1GB) of contiguous memory. I'm trying it on two different hardware configurations, but with the same linux binary. It runs on one system but gives an error "Cannot allocate memory" on the other.

```<code>uint64_t alloc_flags = MAP_PRIVATE | MAP_POPULATE | MAP_ANONYMOUS | MAP_HUGETLB | (30 << MAP_HUGE_SHIFT)

mem->buffer = (char *)mmap(NULL, mem->size, PROT_READ | PROT_WRITE,
                  alloc_flags, mem->fd, 0);
       if (mem->buffer == MAP_FAILED) {
       perror("[ERROR] - mmap() failed with");
       exit(1);
   }
</code>```

Any ideas of what might be the problem, or what to look at?

/proc/meminfo looks about the same on both systems.

I tried without success: echo 20 > /proc/sys/vm/nr_hugepages

EDIT: both systems /sys/kernel/mm/hugepages/ have:
 "hugepages-1048576kB  hugepages-2048kB"

..
/sys/kernel/mm/hugepages/hugepages-1048576kB/free_hugepages reveals 1 on the successful system, and 0 on the failing system!

答:
Having plenty of memory is not enough. Hardware requires each page be contiguous range of physical memory aligned by page size.

If your systems memory is fragmented and doesn't have enough contiguous regions, the allocation will fail.

You can ask kernel to reserve some amount of memory at boot time through kernel parameters:

```<code>hugepagesz=1G hugepages=2
</code>```

This should allocate 2 1GB pages. Note that your CPU needs to have pdpe1gb flag set:

```<code>grep pdpe1gb /proc/cpuinfo
</code>```

This should not be a problem since all CPUs since Westmere (released in 2010).

Body:
I'm trying to run some code I didn't write, that needs a large chunk (~1GB) of contiguous memory. I'm trying it on two different hardware configurations, but with the same linux binary. It runs on one system but gives an error "Cannot allocate memory" on the other.

uint64_t alloc_flags = MAP_PRIVATE | MAP_POPULATE | MAP_ANONYMOUS | MAP_HUGETLB | (30 << MAP_HUGE_SHIFT)

mem->buffer = (char *)mmap(NULL, mem->size, PROT_READ | PROT_WRITE,
                  alloc_flags, mem->fd, 0);
       if (mem->buffer == MAP_FAILED) {
       perror("[ERROR] - mmap() failed with");
       exit(1);
   }

Any ideas of what might be the problem, or what to look at?

/proc/meminfo looks about the same on both systems.

I tried without success: echo 20 > /proc/sys/vm/nr_hugepages

EDIT: both systems /sys/kernel/mm/hugepages/ have:
 "hugepages-1048576kB  hugepages-2048kB"

..
/sys/kernel/mm/hugepages/hugepages-1048576kB/free_hugepages reveals 1 on the successful system, and 0 on the failing system!

Body:
Having plenty of memory is not enough. Hardware requires each page be contiguous range of physical memory aligned by page size.

If your systems memory is fragmented and doesn't have enough contiguous regions, the allocation will fail.

You can ask kernel to reserve some amount of memory at boot time through kernel parameters:

hugepagesz=1G hugepages=2

This should allocate 2 1GB pages. Note that your CPU needs to have pdpe1gb flag set:

grep pdpe1gb /proc/cpuinfo

This should not be a problem since all CPUs since Westmere (released in 2010).


问:
Convert sysdate to BST(British Summer Time)
I have a Java api which gets the data from oracle database which is in ET timezone. I want to query that table using sysdate on 2 columns but the sysdate should be picked as current BST date value not as ET date value.

```<code>select * from customers where sysdate between mem_registered_date and mem_deregistered_date;
</code>```

How this can be done? please help

答:
If querying a column with a date-only value, without any time-of-day nor any time zone, that is, a column of a type akin to the SQL-standard DATE type, then use Java class LocalDate.

Generally best to use  half-open definition of a span of time, where the beginning is inclusive while the ending is exclusive. This allows spans to nearly abut one another without gaps or overlap. So never use the SQL command BETWEEN for date-time ranges, as it is fully-closed (both beginning and ending are inclusive).

Get today’s date as seen in the wall-clock time used by the people of a particular region (a time zone).

BST is not a real time zone. For British time, use Europe/London.

```<code>ZoneId z = ZoneId.of( "Europe/London" ) ;
LocalDate today = LocalDate.now( z ) ;
</code>```

The SQL will look something like this:

```<code>SELECT *
FROM event_
WHERE ? >= start_
AND ? < end_
;
</code>```

Fill in the placeholders.

```<code>myPreparedStatement.setObject( 1 , today ) ;
myPreparedStatement.setObject( 2 , today ) ;
</code>```

Load the date values from database into Java.

```<code>LocalDate start = myResultSet.getObject( … , LocalDate.class ) ;
</code>```

TIMESTAMP WITHOUT TIME ZONE

The misnamed DATE in the Oracle database actually represents a date with time-of-date without the context of a time zone or offset-from-UTC. As such, this type cannot represent a moment, a specific point on the timeline. It the value is noon on the 23rd of January next year, we cannot know if that is noon in Tokyo, Toulouse, or Toledo — all different moments several hours apart. This DATE type is akin to the SQL-standard type TIMESTAMP WITHOUT TIME ZONE.

So for this data type, your question asking about time zones makes no sense. Apple and oranges. Involving time zones means you are tracking moments, specific points on the timeline. But the Oracle DATE cannot represent moments as discussed above.

To track moments, your should be using a column of a type akin to the SQL-standard TIMESTAMP WITH TIME ZONE.

Body:
I have a Java api which gets the data from oracle database which is in ET timezone. I want to query that table using sysdate on 2 columns but the sysdate should be picked as current BST date value not as ET date value.

select * from customers where sysdate between mem_registered_date and mem_deregistered_date;

How this can be done? please help

Body:
If querying a column with a date-only value, without any time-of-day nor any time zone, that is, a column of a type akin to the SQL-standard DATE type, then use Java class LocalDate.

Generally best to use  half-open definition of a span of time, where the beginning is inclusive while the ending is exclusive. This allows spans to nearly abut one another without gaps or overlap. So never use the SQL command BETWEEN for date-time ranges, as it is fully-closed (both beginning and ending are inclusive).

Get today’s date as seen in the wall-clock time used by the people of a particular region (a time zone).

BST is not a real time zone. For British time, use Europe/London.

ZoneId z = ZoneId.of( "Europe/London" ) ;
LocalDate today = LocalDate.now( z ) ;

The SQL will look something like this:

SELECT *
FROM event_
WHERE ? >= start_
AND ? < end_
;

Fill in the placeholders.

myPreparedStatement.setObject( 1 , today ) ;
myPreparedStatement.setObject( 2 , today ) ;

Load the date values from database into Java.

LocalDate start = myResultSet.getObject( … , LocalDate.class ) ;

TIMESTAMP WITHOUT TIME ZONE

The misnamed DATE in the Oracle database actually represents a date with time-of-date without the context of a time zone or offset-from-UTC. As such, this type cannot represent a moment, a specific point on the timeline. It the value is noon on the 23rd of January next year, we cannot know if that is noon in Tokyo, Toulouse, or Toledo — all different moments several hours apart. This DATE type is akin to the SQL-standard type TIMESTAMP WITHOUT TIME ZONE.

So for this data type, your question asking about time zones makes no sense. Apple and oranges. Involving time zones means you are tracking moments, specific points on the timeline. But the Oracle DATE cannot represent moments as discussed above.

To track moments, your should be using a column of a type akin to the SQL-standard TIMESTAMP WITH TIME ZONE.


问:
What are the options when it comes to handling Data Lineage in Snowflake?
Any ideas/options about handling Data Lineage in Snowflake? We are following a microservice architecture in which we are running a set of stored procedures that contain quite a few SQL queries as soon as certain events are triggered.

Example: When Table A is populated execute SP_Populate_Table_B and the result is that Table B is populated. We have a big set of SPs as we are populating the Staging Area, DataVault and our Dimensional Model.

We are in the lookout for any good way of handling all the metadata around this microservice way of performing our ETL. Basically automated way to track dependencies between tables, visualize the orchestration, have a better way to handle the changes of the SPs when tables are changed etc.

Can you please advice for some frameworks or tools, preferably open-source, that you have tried for Snowflake? Will DBT be a solution to that?

Thank you
Pantelis

答:
I'm not 100% sure if it supports snowflake just yet but I'd highly recommend looking into Packyderm. I believe it was built to solve just this kind of problem. </p>

<p>Might be worth a look or even contributing to if you really want Snowflake support. </p>

Body:
I'm not 100% sure if it supports snowflake just yet but I'd highly recommend looking into Packyderm. I believe it was built to solve just this kind of problem.

Might be worth a look or even contributing to if you really want Snowflake support.


问:
MVC: Best way for a hyperlink to post back to an ActionResult
I'm using a Html.BeginForm but I need a hyperlink to trigger a postback to a ActionResult (similar functionality to a LinkButton).  I don't think that I can use an ActionLink because i'm not routing to a view with the same name as the ActionResult (or have I misunderstood :S).

Any help would be appreciated.

Thanks

答:
I think you have two options (though the first isn't as flexible and can get messy)

1) style your submit button like a hyperlink (easy, but you'll probably end up using Html.BeginAjax or something like that)

2) Style a div, ActionLink, or some other element and serialize the form data on posting back using jQuery

If you can better describe the data being returned, we can better customize the dataType and success parameters below.

```<code>$(function () {
    $('#myButton').click(function (e) {
        e.preventDefault();
        $.ajax({
            url: '/MyController/MySuperAction',
            type: 'POST',
            data: $('#formId').serialize(),
            dataType: 'json',
            success: function (xhr_data) {
                // in this particular example, you'll
                // parse your JSON returned.
            }
        });
    });
});
</code>```

Edit

So, you're controller could look like

```<code>public ActionResult MySuperAction(FormCollection form) {
    // I don't recommend using FormCollection
    // You should stick to the view model pattern

    // process your form
    return Json(new { MyValue = "Textbox value" });
}
</code>```

And you'd need to modify the success function above to something like

```<code>success: function(xhr_data) {
    $('#MyTextBoxID').val(xhr_data.MyValue);
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I think you have two options (though the first isn't as flexible and can get messy)

1) style your submit button like a hyperlink (easy, but you'll probably end up using Html.BeginAjax or something like that)

2) Style a div, ActionLink, or some other element and serialize the form data on posting back using jQuery

If you can better describe the data being returned, we can better customize the dataType and success parameters below.

$(function () {
    $('#myButton').click(function (e) {
        e.preventDefault();
        $.ajax({
            url: '/MyController/MySuperAction',
            type: 'POST',
            data: $('#formId').serialize(),
            dataType: 'json',
            success: function (xhr_data) {
                // in this particular example, you'll
                // parse your JSON returned.
            }
        });
    });
});

Edit

So, you're controller could look like

public ActionResult MySuperAction(FormCollection form) {
    // I don't recommend using FormCollection
    // You should stick to the view model pattern

    // process your form
    return Json(new { MyValue = "Textbox value" });
}

And you'd need to modify the success function above to something like

success: function(xhr_data) {
    $('#MyTextBoxID').val(xhr_data.MyValue);
}


问:
How can you find the index of a list within a list of lists
I know for 1d arrays there is a function called np.in1d that allows you to find the indices of an array that are present in another array, for example:

```<code>a = [0,0,0,24210,0,0,0,0,0,21220,0,0,0,0,0,24410]
b = [24210,24610,24410]

np.in1d(a,b)

yields [False, False, False,  True, False, False, False, False, False,
       False, False, False, False, False, False,  True]
</code>```

I was wondering if there was a command like this for finding lists in a list of lists?

```<code>c = [[1,0,1],[0,0,1],[0,0,0],[0,0,1],[1,1,1]]
d = [[0,0,1],[1,0,1]]

something like np.in2d(c,d)

would yield [True, True, False,  True, False]
</code>```

Edit:  I should add, I tried this with in1d and it flattens the 2d lists so it does not give the correct output.

```<code>I did np.in1d(c,d) and the result was [ True,  True,  True,
True,  True,  True,  True,  True,  True, True,  True,  True,  True,  True,
True]
</code>```

答:
What about this?</p>

```<code>[x in d for x in c]
</code>```

Body:
I know for 1d arrays there is a function called np.in1d that allows you to find the indices of an array that are present in another array, for example:

a = [0,0,0,24210,0,0,0,0,0,21220,0,0,0,0,0,24410]
b = [24210,24610,24410]

np.in1d(a,b)

yields [False, False, False,  True, False, False, False, False, False,
       False, False, False, False, False, False,  True]

I was wondering if there was a command like this for finding lists in a list of lists?

c = [[1,0,1],[0,0,1],[0,0,0],[0,0,1],[1,1,1]]
d = [[0,0,1],[1,0,1]]

something like np.in2d(c,d)

would yield [True, True, False,  True, False]

Edit:  I should add, I tried this with in1d and it flattens the 2d lists so it does not give the correct output.

I did np.in1d(c,d) and the result was [ True,  True,  True,
True,  True,  True,  True,  True,  True, True,  True,  True,  True,  True,
True]

Body:
What about this?

[x in d for x in c]


问:
Spring Vault Integration with Spring Boot App
I am trying to integrate Spring Vault with my application but as soon as I run the application it is throwing exception. I am following Spring IO Documents since I am new to the vault integration but couldn't figure out the exception because I am providing all the information required in the bootstrap
file.

This is my POM file

```<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.6.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <dependencies>

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

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-vault-config</artifactId>
            <version>2.2.2.RELEASE</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-vault-config-databases</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>

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

        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
            <exclusions>
                <exclusion>
                    <groupId>bouncycastle</groupId>
                    <artifactId>bcmail-jdk14</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>bouncycastle</groupId>
                    <artifactId>bcprov-jdk14</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>bouncycastle</groupId>
                    <artifactId>bctsp-jdk14</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.axis2/axis2-adb -->
        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb</artifactId>
            <version>1.7.9</version>
        </dependency>

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

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.9</version>
        </dependency>

        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.6.2</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

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

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <forkCount>0</forkCount>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.3</version>
                <configuration>
                    <destFile>target/jacoco.exec</destFile>
                </configuration>
                <executions>
                    <execution>
                        <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-site</id>
                        <phase>package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.3-SNAPSHOT</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>
</code>```

This is my Bootstrap.yml file

```<code>spring:
   cloud:
   vault:
     profiles: dev
     scheme: http
     port: ****
     host: *********
     authentication: token
</code>```

This is my Config file

```<code> @Configuration
    public class config{

    @Autowired
    Environment environment;

    @Bean
    @Primary
    public DataSource getDataSource() {

        DataSource dataSource = DataSourceBuilder.create()
                .password(environment.getProperty("spring.datasource.password"))
                .username(environment.getProperty("spring.datasource.username"))
                .driverClassName(environment.getProperty("spring.datasource.driver-class-name"))
                .url(environment.getProperty("spring.datasource.url")).build();

        return dataSource;
    }
</code>```

This is my main application

```<code> @SpringBootApplication
 @EnableAutoConfiguration
        public class MainApplication {

        public static void main(String[] args) {
        SpringApplication.run(MainApplication.class, args);

        VaultTemplate vaultTemplate = new VaultTemplate(new VaultEndpoint(),
                new TokenAuthentication("***********"));

        VaultResponseSupport<VaultConfig> response = vaultTemplate.read("********",
        VaultConfig.class);
        System.out.println(response.getData().getUsername());
        System.out.println(response.getData().getPassword());
        }

        }
</code>```

This is the log which I am getting

```<code>2020-05-28 14:48:28.641  WARN 20984 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultPropertySourceLocator' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapPropertySourceConfiguration.class]: Unsatisfied dependency expressed through method 'vaultPropertySourceLocator' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultTemplate' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.core.VaultTemplate]: Factory method 'vaultTemplate' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultSessionManager' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Unsatisfied dependency expressed through method 'vaultSessionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientAuthentication' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.authentication.ClientAuthentication]: Factory method 'clientAuthentication' threw exception; nested exception is java.lang.IllegalArgumentException: Token (spring.cloud.vault.token) must not be empty
2020-05-28 14:48:28.659  INFO 20984 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-05-28 14:48:28.679 ERROR 20984 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultPropertySourceLocator' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapPropertySourceConfiguration.class]: Unsatisfied dependency expressed through method 'vaultPropertySourceLocator' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultTemplate' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.core.VaultTemplate]: Factory method 'vaultTemplate' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultSessionManager' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Unsatisfied dependency expressed through method 'vaultSessionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientAuthentication' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.authentication.ClientAuthentication]: Factory method 'clientAuthentication' threw exception; nested exception is java.lang.IllegalArgumentException: Token (spring.cloud.vault.token) must not be empty
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:882) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:212) [spring-cloud-context-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117) [spring-cloud-context-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74) [spring-cloud-context-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) [spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at com.optum.omms.OmmsMemberApiApplication.main(OmmsMemberApiApplication.java:12) [classes!/:0.0.1-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [omms-member-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [omms-member-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [omms-member-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [omms-member-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultTemplate' defined in class path resource
</code>```

答:
You have almost everything correct except two problems in the Bootstrap.yml.

i. Indentation - vault is a sub property of cloud, so you'll have to push it with an additional space. Yaml takes indentation very seriously.

ii. Missing required attribute - token is a required attribute with your config so you'll have to add one.

These problems were noted in the error message you posted.

```<code>... Token (spring.cloud.vault.token) must not be empty.
</code>```

Following Bootstrap.yml loads the context you noted in the MainApplication just fine:

```<code>spring:
  cloud:
    vault:
      profiles: dev
      scheme: http
      port: 1111
      host: 1.1.1.1
      authentication: token
      token: s3cr3t
</code>```

Body:
I am trying to integrate Spring Vault with my application but as soon as I run the application it is throwing exception. I am following Spring IO Documents since I am new to the vault integration but couldn't figure out the exception because I am providing all the information required in the bootstrap
file.

This is my POM file

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.6.RELEASE</version>
        <relativePath />
    </parent>

    <dependencies>

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

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-vault-config</artifactId>
            <version>2.2.2.RELEASE</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-vault-config-databases</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>

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

        <dependency>
            <groupId>com.lowagie</groupId>
            <artifactId>itext</artifactId>
            <version>2.1.7</version>
            <exclusions>
                <exclusion>
                    <groupId>bouncycastle</groupId>
                    <artifactId>bcmail-jdk14</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>bouncycastle</groupId>
                    <artifactId>bcprov-jdk14</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>bouncycastle</groupId>
                    <artifactId>bctsp-jdk14</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2-adb</artifactId>
            <version>1.7.9</version>
        </dependency>

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

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.8.9</version>
        </dependency>

        <dependency>
            <groupId>org.apache.axis2</groupId>
            <artifactId>axis2</artifactId>
            <version>1.6.2</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.13</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

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

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <forkCount>0</forkCount>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.3</version>
                <configuration>
                    <destFile>target/jacoco.exec</destFile>
                </configuration>
                <executions>
                    <execution>
                        <id>jacoco-initialize</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>jacoco-site</id>
                        <phase>package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.3-SNAPSHOT</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

This is my Bootstrap.yml file

spring:
   cloud:
   vault:
     profiles: dev
     scheme: http
     port: ****
     host: *********
     authentication: token

This is my Config file

 @Configuration
    public class config{

    @Autowired
    Environment environment;

    @Bean
    @Primary
    public DataSource getDataSource() {

        DataSource dataSource = DataSourceBuilder.create()
                .password(environment.getProperty("spring.datasource.password"))
                .username(environment.getProperty("spring.datasource.username"))
                .driverClassName(environment.getProperty("spring.datasource.driver-class-name"))
                .url(environment.getProperty("spring.datasource.url")).build();

        return dataSource;
    }

This is my main application

 @SpringBootApplication
 @EnableAutoConfiguration
        public class MainApplication {

        public static void main(String[] args) {
        SpringApplication.run(MainApplication.class, args);

        VaultTemplate vaultTemplate = new VaultTemplate(new VaultEndpoint(),
                new TokenAuthentication("***********"));

        VaultResponseSupport<VaultConfig> response = vaultTemplate.read("********",
        VaultConfig.class);
        System.out.println(response.getData().getUsername());
        System.out.println(response.getData().getPassword());
        }

        }

This is the log which I am getting

2020-05-28 14:48:28.641  WARN 20984 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultPropertySourceLocator' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapPropertySourceConfiguration.class]: Unsatisfied dependency expressed through method 'vaultPropertySourceLocator' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultTemplate' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.core.VaultTemplate]: Factory method 'vaultTemplate' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultSessionManager' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Unsatisfied dependency expressed through method 'vaultSessionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientAuthentication' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.authentication.ClientAuthentication]: Factory method 'clientAuthentication' threw exception; nested exception is java.lang.IllegalArgumentException: Token (spring.cloud.vault.token) must not be empty
2020-05-28 14:48:28.659  INFO 20984 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-05-28 14:48:28.679 ERROR 20984 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultPropertySourceLocator' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapPropertySourceConfiguration.class]: Unsatisfied dependency expressed through method 'vaultPropertySourceLocator' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultTemplate' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.core.VaultTemplate]: Factory method 'vaultTemplate' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'vaultSessionManager' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Unsatisfied dependency expressed through method 'vaultSessionManager' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientAuthentication' defined in class path resource [org/springframework/cloud/vault/config/VaultBootstrapConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.vault.authentication.ClientAuthentication]: Factory method 'clientAuthentication' threw exception; nested exception is java.lang.IllegalArgumentException: Token (spring.cloud.vault.token) must not be empty
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:539) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1338) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1177) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:557) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:882) ~[spring-beans-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878) ~[spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:212) [spring-cloud-context-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:117) [spring-cloud-context-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:74) [spring-cloud-context-2.2.2.RELEASE.jar!/:2.2.2.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) [spring-context-5.2.5.RELEASE.jar!/:5.2.5.RELEASE]
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.2.6.RELEASE.jar!/:2.2.6.RELEASE]
        at com.optum.omms.OmmsMemberApiApplication.main(OmmsMemberApiApplication.java:12) [classes!/:0.0.1-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_201]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_201]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_201]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_201]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [omms-member-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [omms-member-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:51) [omms-member-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52) [omms-member-api-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'vaultTemplate' defined in class path resource

Body:
You have almost everything correct except two problems in the Bootstrap.yml.

i. Indentation - vault is a sub property of cloud, so you'll have to push it with an additional space. Yaml takes indentation very seriously.

ii. Missing required attribute - token is a required attribute with your config so you'll have to add one.

These problems were noted in the error message you posted.

... Token (spring.cloud.vault.token) must not be empty.

Following Bootstrap.yml loads the context you noted in the MainApplication just fine:

spring:
  cloud:
    vault:
      profiles: dev
      scheme: http
      port: 1111
      host: 1.1.1.1
      authentication: token
      token: s3cr3t


问:
npm command not found error while running docker container
I am trying some something out with gitlab-runner image,

```<code>    FROM gitlab/gitlab-runner:alpine
    WORKDIR /app
    COPY . /app
    RUN apk add yarn && yarn install

    RUN yarn --version        # this layer prints 1.16.0

    RUN ng build --prod
    EXPOSE 3000
    CMD ["yarn", "run", "start"]
</code>```

above is the docker file I have created

```<code>    docker build -t runner:1 .
</code>```

I was able to build the image successfully

```<code>    docker run -p 3000:3000 runner:1
</code>```

but when I try to run the container it gives me below error

```<code>`*FATAL: Command yarn not found.*`
</code>```

not sure about the behavior, if it is able to install yarn (apk add yarn) in base images and install the dependencies using yarn install then how it is not able to find the yarn command while running the container? Where I am going wrong.

Also at which directory yarn is installed in the alpine ?

I know it is not an efficient docker file, but I am trying to run the container first before optimizing it.

答:
To build your app you shouldn't use gitlab-runner image, but a 'node' one.

Gilab-runner image is for running a gitlab agent which can be connected to docker engine and spawn the node container in which you will execute your build, in your case a docker image build.

To use gilab you need to prepare a gitlab-ci file where you will define what steps and which 'services' you need to do your build.

Tl;dr: change base image to node:latest and as a entirely separate work setup gitlab runner.

However if your aim is to have your application to extend gitlab runner, try docker multistage builds.

First, use node:latest image to build your app, and then copy the build output into gitlab-runner.

Runtime images such as gitlab-runner are stripped from build tools like yarn or npm, that's why your image fails. Main goal is to keep runtime images as small as possible and sdk's are not needed and sometimes dangerous when it comes to production-level work.

Body:
I am trying some something out with gitlab-runner image,

    FROM gitlab/gitlab-runner:alpine
    WORKDIR /app
    COPY . /app
    RUN apk add yarn && yarn install

    RUN yarn --version        # this layer prints 1.16.0

    RUN ng build --prod
    EXPOSE 3000
    CMD ["yarn", "run", "start"]

above is the docker file I have created

    docker build -t runner:1 .

I was able to build the image successfully

    docker run -p 3000:3000 runner:1

but when I try to run the container it gives me below error

`*FATAL: Command yarn not found.*`

not sure about the behavior, if it is able to install yarn (apk add yarn) in base images and install the dependencies using yarn install then how it is not able to find the yarn command while running the container? Where I am going wrong.

Also at which directory yarn is installed in the alpine ?

I know it is not an efficient docker file, but I am trying to run the container first before optimizing it.


问:
How to add the widgets dynamically to column in Flutter?
I have added a few widgets inside the  ListView. So that I can scroll all widgets. Now I required to add one more widget to the ListView to load the list of comments. I can not add the ListView inside the ListView. And moreover, I do not require the separate scroll for my comments.  It should be scroll along with the widgets inside the ListView. So I planned to add the Column instead of ListView. Could any help to add my comments dynamically in the Columns?

```<code>new Expanded(
          child:
          new ListView(
            shrinkWrap: true,
            children: <Widget>[

              // Title

              new Padding(padding: const EdgeInsets.only(
                  top: 10.00, left: 10.00),
                child: new Text(
                  _feed.title, textAlign: TextAlign.start,),
              ),

              // content

              new Container(
                child: new Text(
                  _feed.content, textAlign: TextAlign.start,),
              ),

              // Comments List will go here

            ],
          ),
        ),
</code>```

答:
By maintaining a reference to the Column object, the .children field/property can be referenced after the Column object has been declared - like so:

```<code>Column someColumn = Column(
  children: [],
);

someColumn.children.add(Text('Hello 123'));
</code>```

Body:
I have added a few widgets inside the  ListView. So that I can scroll all widgets. Now I required to add one more widget to the ListView to load the list of comments. I can not add the ListView inside the ListView. And moreover, I do not require the separate scroll for my comments.  It should be scroll along with the widgets inside the ListView. So I planned to add the Column instead of ListView. Could any help to add my comments dynamically in the Columns?

new Expanded(
          child:
          new ListView(
            shrinkWrap: true,
            children: <Widget>[

              // Title

              new Padding(padding: const EdgeInsets.only(
                  top: 10.00, left: 10.00),
                child: new Text(
                  _feed.title, textAlign: TextAlign.start,),
              ),

              // content

              new Container(
                child: new Text(
                  _feed.content, textAlign: TextAlign.start,),
              ),

              // Comments List will go here

            ],
          ),
        ),

Body:
By maintaining a reference to the Column object, the .children field/property can be referenced after the Column object has been declared - like so:

Column someColumn = Column(
  children: [],
);

someColumn.children.add(Text('Hello 123'));


问:
Visual Studio 2008 Test Sets
Is it possible to group tests together so I can run a subset of all tests available?</p>

答: Assuming you are using VSTT, aka MSTest; You can use the Test Lists feature. </p>

OwnerDisplayName: blu

ContentLicense: CC BY-SA 2.5

Title: Visual Studio 2008 Test Sets

OwnerDisplayName: Phil Price


答:
When SVG images are rendered, horizontal and vertical lines that follow integer coordinates will be spread across the two pixels on either side (above/below horizontal lines, and to the left/right of vertical lines). This makes them appear blurry.

To avoid this, create your design using integer coordinates, then offset the results by half a pixel in the X and Y directions. The results will be much sharper.

Also, it would make more sense to draw the cursor at the dimensions you want instead of at a much larger size that you have to scale down.

Here's a simple cursor drawn with and without a half-pixel offset. You should be able to see it much more clearly with the added offset.

<svg height="16" width="16" viewBox="0 0 16 16">
<path d="M8,1L10.5,4L9,4L9,7L12,7L12,5.5L15,8
         L12,10.5L12,9L9,9L9,12L10.5,12L8,15
         L5.5,12L7,12L7,9L4,9L4,10.5L1,8L4,5.5
         L4,7L7,7L7,4L5.5,4L8,1Z" fill="none"
         stroke="#e00" stroke-width="0.8"
         stroke-miterlimit="2"/>
</svg>

<svg height="16" width="16" viewBox="0 0 16 16">
<path d="M8.5,1.5L11,4.5L9.5,4.5L9.5,7.5
         L12.5,7.5L12.5,6L15.5,8.5L12.5,11
         L12.5,9.5L9.5,9.5L9.5,12.5L11,12.5
         L8.434,15.5L6,12.5L7.5,12.5L7.5,9.5
         L4.5,9.5L4.5,11L1.5,8.5L4.5,6L4.5,7.5
         L7.5,7.5L7.5,4.5L6,4.5L8.5,1.5Z"
         fill="none" stroke="#e00"
         stroke-width="0.8" stroke-miterlimit="2"/>
</svg>```
</div>
</div>
</p>

<h2>Example:</h2>

<p>This is what the second of these images looks like when used as a cursor (i.e., the one offset by ½ a pixel):</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
    cursor: url("data:image/svg+xml,%3Csvg  xmlns='http://www.w3.org/2000/svg' height='16' width='16' viewBox='0 0 16 16'%3E%3Cpath d='M8.5,1.5L11,4.5L9.5,4.5L9.5,7.5L12.5,7.5L12.5,6L15.5,8.5L12.5,11L12.5,9.5L9.5,9.5L9.5,12.5L11,12.5L8.434,15.5L6,12.5L7.5,12.5L7.5,9.5L4.5,9.5L4.5,11L1.5,8.5L4.5,6L4.5,7.5L7.5,7.5L7.5,4.5L6,4.5L8.5,1.5Z' fill='none' stroke='#e00' stroke-width='0.8' stroke-miterlimit='2'/%3E%3C/svg%3E") 8 8, move;
}</code>```

Title: Why is my svg crisp when imported, but blurry as a cursor?

Body:
I was trying to use the following svg image as a cursor for my document:

<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 144 135.92"><defs></defs><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M72,135.92,52.25,103c-.54-.91-.59-7.11.32-8.23l1-1.16,8.06,1.18V78.2H42.18l1.17,7.53-.81.93c-1.47,1.69-7.86.93-8.27.75L0,68,34,48.6c.6-.29,6.9-.9,8.34.48l1,1-1.18,7.61H61.63V41.1l-8.1,1.21-1-1.17c-.91-1.11-.86-7.32-.33-8.21L72,0,91.75,32.91c.5.85.68,7-.3,8.23l-1,1.17-8-1.19V57.7h19.36L100.61,50l1.08-1c1.41-1.27,7.62-.73,8-.54L144,68,110,87.3c-.65.3-6.95,1-8.42-.54l-.91-1,1.17-7.55H82.37V94.8l8.12-1.19,1,1.16c1,1.22.8,7.38.31,8.21Zm-14.82-35L72,125.58l14.82-24.7c0-.36,0-.85,0-1.35L77.05,101V73h31l-1.45,9.37H108L133.24,68l-25.3-14.4h-1.38L108,63H77.14V35l9.67,1.44c0-.51,0-1,0-1.36L72,10.34,57.18,35c0,.36,0,.85,0,1.36L67,34.92V63H36l1.45-9.4H36L10.76,68l25.3,14.37h1.38L36,72.88H66.91v28.06L57.2,99.52C57.19,100,57.18,100.52,57.18,100.89Z"/></g></g></svg>
<svg height="16" width="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 144 135.92"><defs></defs><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M72,135.92,52.25,103c-.54-.91-.59-7.11.32-8.23l1-1.16,8.06,1.18V78.2H42.18l1.17,7.53-.81.93c-1.47,1.69-7.86.93-8.27.75L0,68,34,48.6c.6-.29,6.9-.9,8.34.48l1,1-1.18,7.61H61.63V41.1l-8.1,1.21-1-1.17c-.91-1.11-.86-7.32-.33-8.21L72,0,91.75,32.91c.5.85.68,7-.3,8.23l-1,1.17-8-1.19V57.7h19.36L100.61,50l1.08-1c1.41-1.27,7.62-.73,8-.54L144,68,110,87.3c-.65.3-6.95,1-8.42-.54l-.91-1,1.17-7.55H82.37V94.8l8.12-1.19,1,1.16c1,1.22.8,7.38.31,8.21Zm-14.82-35L72,125.58l14.82-24.7c0-.36,0-.85,0-1.35L77.05,101V73h31l-1.45,9.37H108L133.24,68l-25.3-14.4h-1.38L108,63H77.14V35l9.67,1.44c0-.51,0-1,0-1.36L72,10.34,57.18,35c0,.36,0,.85,0,1.36L67,34.92V63H36l1.45-9.4H36L10.76,68l25.3,14.37h1.38L36,72.88H66.91v28.06L57.2,99.52C57.19,100,57.18,100.52,57.18,100.89Z"/></g></g></svg>

html {
    cursor: url(cursor/move.svg), auto;
}

But it doesn't matter if I change its size to something big (128px) or small, and it doesn't matter if I'm on Chrome, Firefox, or Safari, it is still somewhat pixelated. It is crisp and clean when I import it into the HTML document, but blurry and pixelated when I use it as a cursor. What am I doing wrong?

Body:
When SVG images are rendered, horizontal and vertical lines that follow integer coordinates will be spread across the two pixels on either side (above/below horizontal lines, and to the left/right of vertical lines). This makes them appear blurry.

To avoid this, create your design using integer coordinates, then offset the results by half a pixel in the X and Y directions. The results will be much sharper.

Also, it would make more sense to draw the cursor at the dimensions you want instead of at a much larger size that you have to scale down.

Here's a simple cursor drawn with and without a half-pixel offset. You should be able to see it much more clearly with the added offset.

<!-- Lines following integer coordinates -->
<svg height="16" width="16" viewBox="0 0 16 16">
<path d="M8,1L10.5,4L9,4L9,7L12,7L12,5.5L15,8
         L12,10.5L12,9L9,9L9,12L10.5,12L8,15
         L5.5,12L7,12L7,9L4,9L4,10.5L1,8L4,5.5
         L4,7L7,7L7,4L5.5,4L8,1Z" fill="none"
         stroke="#e00" stroke-width="0.8"
         stroke-miterlimit="2"/>
</svg>

<!-- Lines offset by half a pixel -->
<svg height="16" width="16" viewBox="0 0 16 16">
<path d="M8.5,1.5L11,4.5L9.5,4.5L9.5,7.5
         L12.5,7.5L12.5,6L15.5,8.5L12.5,11
         L12.5,9.5L9.5,9.5L9.5,12.5L11,12.5
         L8.434,15.5L6,12.5L7.5,12.5L7.5,9.5
         L4.5,9.5L4.5,11L1.5,8.5L4.5,6L4.5,7.5
         L7.5,7.5L7.5,4.5L6,4.5L8.5,1.5Z"
         fill="none" stroke="#e00"
         stroke-width="0.8" stroke-miterlimit="2"/>
</svg>

Example:

This is what the second of these images looks like when used as a cursor (i.e., the one offset by ½ a pixel):

* {
    cursor: url("data:image/svg+xml,%3Csvg  xmlns='http://www.w3.org/2000/svg' height='16' width='16' viewBox='0 0 16 16'%3E%3Cpath d='M8.5,1.5L11,4.5L9.5,4.5L9.5,7.5L12.5,7.5L12.5,6L15.5,8.5L12.5,11L12.5,9.5L9.5,9.5L9.5,12.5L11,12.5L8.434,15.5L6,12.5L7.5,12.5L7.5,9.5L4.5,9.5L4.5,11L1.5,8.5L4.5,6L4.5,7.5L7.5,7.5L7.5,4.5L6,4.5L8.5,1.5Z' fill='none' stroke='#e00' stroke-width='0.8' stroke-miterlimit='2'/%3E%3C/svg%3E") 8 8, move;
}


问:
How to switch datasources in SSRS report
I have a report and which is coming from database MasterDB. Now I have created a copy of the same database named MasterArchive. I have created parameters for databases to display in dropdown. So, When user select MasterDB from select DataSource dropdown then datasource should change according to selection.

how to change the datasource based on the selection?

Can anyone please guide me how to achieve this.

答:
You can actually write an expression for your connection string by clicking that fx button below the Build button. For example, the expression would be something like:

```<code>="Data Source=...;Initial Catalog=" + Parameters!DataSource.Value
</code>```

Body:
You can actually write an expression for your connection string by clicking that fx button below the Build button. For example, the expression would be something like:

="Data Source=...;Initial Catalog=" + Parameters!DataSource.Value


问:
How to allow cross site origin requests in Google App Engine?
I have a simple API made with Express that is returning json. The Express server is running on Google App Engine. I'm using cors (https://www.npmjs.com/package/cors) to enable ALL CORS-requests, but I still get "No 'Access-Control-Allow-Origin' header is present on the requested resource." when doing AJAX requests from a SPA application.

app.use(cors())

Default settings for above according to the documentation is:

{ "origin": "*",
"methods": "GET,HEAD,PUT,PATCH,POST,DELETE",
"preflightContinue": false,
"optionsSuccessStatus": 204
}

That should be enough since I'm only doing a simple GET-request from my SPA.

Any ideas?

答:
As I answered here, https://stackoverflow.com/a/62075272/2235936

Don't need those handlers stuff in app.yaml, just set CORS on the G storage bucket.