问:
Boostrap image not responsive in safari
I  realized my website is not working on safari (desktop and mobile). For some reason the images are not responsive. I used a Bootstrap theme, the website is simple. Please help!

website: www.scanek.com

HTML:

```<code><section id="portfolio" class="pfblock">
    <div class="container">
        <div class="row">

            <div class="col-sm-6 col-sm-offset-3">

                <div class="pfblock-header wow fadeInUp">
                    <h2 class="pfblock-title">Categories</h2>
                    <div class="pfblock-subtitle">

                    </div>
                </div>

            </div>

        </div><!-- .row -->

        <div class="row">

            <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
                <div class="grid wow zoomIn">
                    <a href="categories/kitchen/index.html">
                    <figure class="effect-bubba">
                        <img src="assets/images/kitchens.jpg" alt="img01" class="img-responsive" />
                        <figcaption>
                            <h2> <span>Kitchens</span></h2>
                            <p></p>
                        </figcaption>
                    </figure>
                    </a>
                </div>

            </div>

            <div class="col-xs-12 col-sm-6  col-md-4 col-lg-4">
                <div class="grid wow zoomIn">
                    <a href="categories/bathroom//bathroom1/index.html">
                    <figure class="effect-bubba">
                        <img src="assets/images/bathrooms.jpg" alt="img01"/>
                        <figcaption>
                            <h2> <span>Bathrooms</span></h2>
                            <p></p>
                        </figcaption>
                    </figure>
                    </a>
                </div>

            </div>

            <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
                <div class="grid wow zoomIn">
                   <a href="categories/fixtures/index.html">
                    <figure class="effect-bubba">
                        <img src="assets/images/fixtures.jpg" alt="img01"/>
                        <figcaption>
                            <h2>House<span> Fixtures</span></h2>
                            <p></p>
                        </figcaption>
                    </figure>
                    </a>
                </div>

            </div>

        </div>

    </div><!-- .container -->

</section>
</code>```

CSS:

```<code>img {
max-width: 100%;
width: 100%;
height: auto;
}

.grid figure img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
opacity: 0.8;

}

figure.effect-bubba img {
opacity: 0.75;
-webkit-transition: opacity 0.35s;
transition: opacity 0.35s;
}
</code>```

答:
In addiion to the CSS typo on img width(should be width: 100%;), you had .img-reponsive only on one image set.

Set .img-responsive on all images.

Check resizing on following fiddle: https://jsfiddle.net/Syden/5mfvj9v2/20/

Snippet below:

img {
  max-width: 100%;
  width: 100%;
  height: auto;
}

.grid figure img {
  position: relative;
  display: block;
  min-height: 100%;
  max-width: 100%;
  opacity: 0.8;
}

figure.effect-bubba img {
  opacity: 0.75;
  -webkit-transition: opacity 0.35s;
  transition: opacity 0.35s;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<section id="portfolio" class="pfblock">
  <div class="container">
    <div class="row">
      <div class="col-sm-6 col-sm-offset-3">
        <div class="pfblock-header wow fadeInUp">
          <h2 class="pfblock-title">Categories</h2>
          <div class="pfblock-subtitle">
          </div>
        </div>
      </div>
    </div>
    <!-- .row -->
    <div class="row">
      <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
        <div class="grid wow zoomIn">

            <figure class="effect-bubba">
              <img src="https://placehold.it/200x500" alt="img01" class="img-responsive" />
              <figcaption>
                <h2> <span>Kitchens</span></h2>
                <p></p>
              </figcaption>
            </figure>

        </div>
      </div>
      <div class="col-xs-12 col-sm-6  col-md-4 col-lg-4">
        <div class="grid wow zoomIn">

            <figure class="effect-bubba">
              <img src="https://placehold.it/200x500" alt="img01" class="img-responsive" />
              <figcaption>
                <h2> <span>Bathrooms</span></h2>
                <p></p>
              </figcaption>
            </figure>

        </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
        <div class="grid wow zoomIn">

            <figure class="effect-bubba">
              <img src="https://placehold.it/200x500" alt="img01" class="img-responsive" />
              <figcaption>
                <h2>House<span> Fixtures</span></h2>
                <p></p>
              </figcaption>
            </figure>

        </div>
      </div>
    </div>
  </div>
  <!-- .container -->
</section></code>```

Title: Boostrap image not responsive in safari

Body:
I  realized my website is not working on safari (desktop and mobile). For some reason the images are not responsive. I used a Bootstrap theme, the website is simple. Please help!

website: www.scanek.com

HTML:

Categories

 Kitchens

 Bathrooms

House Fixtures

CSS:

img {
max-width: 100%;
width: 100%;
height: auto;
}

.grid figure img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
opacity: 0.8;

}

figure.effect-bubba img {
opacity: 0.75;
-webkit-transition: opacity 0.35s;
transition: opacity 0.35s;
}

Body:
In addiion to the CSS typo on img width(should be width: 100%;), you had .img-reponsive only on one image set.

Set .img-responsive on all images.

Check resizing on following fiddle: https://jsfiddle.net/Syden/5mfvj9v2/20/

Snippet below:

img {
  max-width: 100%;
  width: 100%;
  height: auto;
}

.grid figure img {
  position: relative;
  display: block;
  min-height: 100%;
  max-width: 100%;
  opacity: 0.8;
}

figure.effect-bubba img {
  opacity: 0.75;
  -webkit-transition: opacity 0.35s;
  transition: opacity 0.35s;
}

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<section id="portfolio" class="pfblock">
  <div class="container">
    <div class="row">
      <div class="col-sm-6 col-sm-offset-3">
        <div class="pfblock-header wow fadeInUp">
          <h2 class="pfblock-title">Categories</h2>
          <div class="pfblock-subtitle">
          </div>
        </div>
      </div>
    </div>
    <!-- .row -->
    <div class="row">
      <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
        <div class="grid wow zoomIn">
          <a href="categories/kitchen/index.html">
            <figure class="effect-bubba">
              <img src="https://placehold.it/200x500" alt="img01" class="img-responsive" />
              <figcaption>
                <h2> <span>Kitchens</span></h2>
                <p></p>
              </figcaption>
            </figure>
          </a>
        </div>
      </div>
      <div class="col-xs-12 col-sm-6  col-md-4 col-lg-4">
        <div class="grid wow zoomIn">
          <a href="categories/bathroom//bathroom1/index.html">
            <figure class="effect-bubba">
              <img src="https://placehold.it/200x500" alt="img01" class="img-responsive" />
              <figcaption>
                <h2> <span>Bathrooms</span></h2>
                <p></p>
              </figcaption>
            </figure>
          </a>
        </div>
      </div>
      <div class="col-xs-12 col-sm-6 col-md-4 col-lg-4">
        <div class="grid wow zoomIn">
          <a href="categories/fixtures/index.html">
            <figure class="effect-bubba">
              <img src="https://placehold.it/200x500" alt="img01" class="img-responsive" />
              <figcaption>
                <h2>House<span> Fixtures</span></h2>
                <p></p>
              </figcaption>
            </figure>
          </a>
        </div>
      </div>
    </div>
  </div>
  <!-- .container -->
</section>


来源: stackexchange

问:
Constraints for UIcollectionView
In ViewController I insert CollectionView using this code:

```<code>HomeMenuView = UICollectionView(frame: self.view.bounds, collectionViewLayout: UICollectionViewFlowLayout())
</code>```

I want to use constraints with visual format to frame the CollectionView between two objects( Top Image, bottom: button).

PS: Without using storyboard, code only.

答:
I assume that your ImageView are added and properly setup with the needed constraints, also your button,

```<code>self.addSubview(HomeMenuView);
self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[HomeMenuView]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["HomeMenuView":HomeMenuView,"imageView":self.yourImageView,"button":self.yourButton]));
self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:[imageView]-0-[HomeMenuView]-0-[button]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["HomeMenuView":HomeMenuView,"imageView":self.yourImageView,"button":self.yourButton]));
</code>```

I also suggest you check this https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html

I hope this helps

ContentLicense: CC BY-SA 3.0

Title: Constraints for UIcollectionView

Body:
In ViewController I insert CollectionView using this code:

HomeMenuView = UICollectionView(frame: self.view.bounds, collectionViewLayout: UICollectionViewFlowLayout())

I want to use constraints with visual format to frame the CollectionView between two objects( Top Image, bottom: button).

PS: Without using storyboard, code only.

Body:
I assume that your ImageView are added and properly setup with the needed constraints, also your button,

self.addSubview(HomeMenuView);
self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[HomeMenuView]-0-|", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["HomeMenuView":HomeMenuView,"imageView":self.yourImageView,"button":self.yourButton]));
self.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:[imageView]-0-[HomeMenuView]-0-[button]", options: NSLayoutFormatOptions(rawValue: 0), metrics: nil, views: ["HomeMenuView":HomeMenuView,"imageView":self.yourImageView,"button":self.yourButton]));

I also suggest you check this https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html

I hope this helps


问:
Does invokeAny cancel all the threads in a Thread pool or only callables?
I'm creating a fixed size ExecutorService, which is going to be accessed from multiple threads.

```<code>ExecutorService executorService = Executors.newFixedThreadPool(2);
</code>```

Then I'm calling invokeAny from two different threads using the same ExecutorService.

```<code>executorService.invokeAny(listCallables);
</code>```

So there is a possibility that in the thread pool there can be multiple tasks called from different threads.

As per the invokeAny documentation:

Upon normal or exceptional return, tasks that have not completed are cancelled.

My question is, upon successful return of invokeAny, will it cancel all the threads which are in the thread pool or will it cancel only the tasks which are called in separate threads?

答:
Upon normal return of invokeAny, the threadpool will cancel all uncompleted tasks. You can refer to my example:

```<code>package com.pechen;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

public class SleepSecondsCallable implements Callable<String> {
    private String name;

    private int seconds;

    public SleepSecondsCallable(String name, int seconds) {
        this.name = name;
        this.seconds = seconds;
    }

    public String call() throws Exception {
        System.out.println(name + ",begin to execute");

        try {
            TimeUnit.SECONDS.sleep(seconds);
        } catch (InterruptedException e) {
            System.out.println(name + " was disturbed during sleeping.");
            e.printStackTrace();
            return name + ",fails to execute";
        }

        return name + ",success to execute";
    }

}
</code>```

The main class:

```<code>package com.pechen;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Main {

    public static void main(String[] args) throws InterruptedException, ExecutionException {
            ExecutorService executorService = Executors.newFixedThreadPool(3);

            List<Callable<String>> tasks = new ArrayList<Callable<String>>();

            tasks.add(new SleepSecondsCallable("t1", 2));
            tasks.add(new SleepSecondsCallable("t2", 1));

            String result = executorService.invokeAny(tasks);
            System.out.println(result);
            executorService.shutdown();

    }

}
</code>```

The output:

```<code>t1,begin to execute
t2,begin to execute
t2,success to execute
t1 was disturbed during sleeping.
java.lang.InterruptedException: sleep interrupted
    at java.lang.Thread.sleep(Native Method)
    at java.lang.Thread.sleep(Unknown Source)
    at java.util.concurrent.TimeUnit.sleep(Unknown Source)
    at com.pechen.SleepSecondsCallable.call(SleepSecondsCallable.java:20)
    at com.pechen.SleepSecondsCallable.call(SleepSecondsCallable.java:1)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
</code>```

You can see, specify thread t2 to sleep for 1 second and t1 for 2. When t2 successfully returns, theadpool interupts the execution of t1.

Body:
I'm creating a fixed size ExecutorService, which is going to be accessed from multiple threads.

ExecutorService executorService = Executors.newFixedThreadPool(2);

Then I'm calling invokeAny from two different threads using the same ExecutorService.

executorService.invokeAny(listCallables);

So there is a possibility that in the thread pool there can be multiple tasks called from different threads.

As per the invokeAny documentation:

Upon normal or exceptional return, tasks that have not completed are cancelled.

My question is, upon successful return of invokeAny, will it cancel all the threads which are in the thread pool or will it cancel only the tasks which are called in separate threads?

Body:
Upon normal return of invokeAny, the threadpool will cancel all uncompleted tasks. You can refer to my example:

package com.pechen;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

public class SleepSecondsCallable implements Callable<String> {
    private String name;

    private int seconds;

    public SleepSecondsCallable(String name, int seconds) {
        this.name = name;
        this.seconds = seconds;
    }

    public String call() throws Exception {
        System.out.println(name + ",begin to execute");

        try {
            TimeUnit.SECONDS.sleep(seconds);
        } catch (InterruptedException e) {
            System.out.println(name + " was disturbed during sleeping.");
            e.printStackTrace();
            return name + ",fails to execute";
        }

        return name + ",success to execute";
    }

}

The main class:

package com.pechen;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Main {

    public static void main(String[] args) throws InterruptedException, ExecutionException {
            ExecutorService executorService = Executors.newFixedThreadPool(3);

            List<Callable<String>> tasks = new ArrayList<Callable<String>>();

            tasks.add(new SleepSecondsCallable("t1", 2));
            tasks.add(new SleepSecondsCallable("t2", 1));

            String result = executorService.invokeAny(tasks);
            System.out.println(result);
            executorService.shutdown();

    }

}

The output:

t1,begin to execute
t2,begin to execute
t2,success to execute
t1 was disturbed during sleeping.
java.lang.InterruptedException: sleep interrupted
    at java.lang.Thread.sleep(Native Method)
    at java.lang.Thread.sleep(Unknown Source)
    at java.util.concurrent.TimeUnit.sleep(Unknown Source)
    at com.pechen.SleepSecondsCallable.call(SleepSecondsCallable.java:20)
    at com.pechen.SleepSecondsCallable.call(SleepSecondsCallable.java:1)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

You can see, specify thread t2 to sleep for 1 second and t1 for 2. When t2 successfully returns, theadpool interupts the execution of t1.


问:
Why is my page reloading even though I have event.preventDefault (form handling jquery + node.js)
I am using jQuery to asynchronously post my data to my db using node.js and express.js

Here is roughly what I am doing:

index.html:

```<code><form id='mailer' action='/mail/new' method='post'>
  <input name='mycontent'/>
  <input type='submit'/>
</form>
</code>```

script.js:

```<code>$("#mailer").submit(function(e){
  e.preventDefault();
  $.post('/mailer/new',{mycontent:mycontent});
});
</code>```

app.js:

```<code>app.post("/mailer/new",function(){
  //insert into database
}
</code>```

So it is essentially submitting to my database but ignoring the e.preventDefault because my page shows the loader wheel when I press submit

答:
Found the answer by console logging the event object. Turns out the event object (atleast while using jquery) doesn't have a 'preventDefault' function. But rather has an 'isPreventDefault()' function which takes in true or false.

I just replaced the e.preventDefault with e.isPreventDefault(true) and this fixed it and it is not reloading now

Body:
I am using jQuery to asynchronously post my data to my db using node.js and express.js

Here is roughly what I am doing:

index.html:

<form id='mailer' action='/mail/new' method='post'>
  <input name='mycontent'/>
  <input type='submit'/>
</form>

script.js:

$("#mailer").submit(function(e){
  e.preventDefault();
  $.post('/mailer/new',{mycontent:mycontent});
});

app.js:

app.post("/mailer/new",function(){
  //insert into database
}

So it is essentially submitting to my database but ignoring the e.preventDefault because my page shows the loader wheel when I press submit


问:
Jenkins CI configuration on Ubuntu for multiple access over the internet
I just set up a jenkins instance on an ubuntu VM, everything works well as I am able to access it via http://localhost:8080, however, I am trying to enable access to the server by multiple users on multiple hosts within the LAN and even outside the LAN. What is the best way to achieve this?

Modifying the "URL" via "Configure System" link on Jenkins Dashboard isnt working.

答: I was later able to fix this problem by the same method i was trying before i.e modifying the "URL" via "Configure System" link on Jenkins Dashboard. It wasnt working before because I had a firewall rule restricting access via port 8080 </p>


问:
tfs build server - string interpolation $ Character is not valid
i am using string interpolation using $ in my code. It compiles fine but when i check in my code, the build server throws an error BC30037: Character is not valid. Following is an example on how i have used string interpolation:

```<code>dim r = New RadNode($"{acq.FormNo} -  ${CInt(acq.TotalAmount)}", icon:=RadTreeIcons.RedTriangle)
</code>```

The build server has Visual Studio 2015 Entreprise edition installed.

If i run this from command prompt:

C:\Program Files (x86)\MSBuild\14.0\Bin>MSBuild /tv:14.0 "Proj.sln", the code compiles file. However if i change the above argument to

C:\Program Files (x86)\MSBuild\14.0\Bin>MSBuild /tv:12.0 "Proj.sln", i get the same error

I have also made these changes:

i have set the MSBuildArguments Property to /p:VisualStudioVersion=14.0 and also changed the TFSBuild.proj file and changed this line to <Project DefaultTargets="DesktopBuild" xmlns="schemas.microsoft.com/developer/msbuild/2003"; ToolsVersion="14.0">" but same issue is happening.

Changed the (web vbproj) file and changed ToolSet Version to 14.0 from 12.0. Other vb projects part of the solution are still targeting 12.0 but gets compiled in dll as part of web vb project.

答:
Answer located here solved my problem:

BuildActivity ignores ToolsVersion

For those of us not living inside build templates every day here's the steps that got it working for me:

First find the template associated with your build (if you already know where to find it skip a couple steps).

Just right click the build definition and select Edit build definition
Select the Process tab and you'll see the name of the template (quite likely to be DefaultTemplate if you haven't customized it). On the far right click Show details to see the path for the template.

Go to the Home tab under Team explorer and click Source control explorer

Find the template file and double click to edit it. It should come up in a graphical view like this. Scroll till you find Run MSBuild for Project

Click on this item which will immediately bring up properties

Click on the little icon on the right - don't try and type it in because it'll probably explode and crash Visual Studio.
Enter IN QUOTES the following "C:\Program Files (x86)\MSBuild\14.0\bin"

NOW FOR THE MOST IMPORTANT PART

For me the Run MSBuild for Project was in TWO places.

So I just repeated the above steps in both places, and then after I checked in the .xaml file my build FINALLY worked fine.

You may need to recycle the agent / controller from within the TFS tool.

Body:
i am using string interpolation using $ in my code. It compiles fine but when i check in my code, the build server throws an error BC30037: Character is not valid. Following is an example on how i have used string interpolation:

dim r = New RadNode($"{acq.FormNo} -  ${CInt(acq.TotalAmount)}", icon:=RadTreeIcons.RedTriangle)

The build server has Visual Studio 2015 Entreprise edition installed.

If i run this from command prompt:

C:\Program Files (x86)\MSBuild\14.0\Bin>MSBuild /tv:14.0 "Proj.sln", the code compiles file. However if i change the above argument to

C:\Program Files (x86)\MSBuild\14.0\Bin>MSBuild /tv:12.0 "Proj.sln", i get the same error

I have also made these changes:

i have set the MSBuildArguments Property to /p:VisualStudioVersion=14.0 and also changed the TFSBuild.proj file and changed this line to <Project DefaultTargets="DesktopBuild" xmlns="schemas.microsoft.com/developer/msbuild/2003"; ToolsVersion="14.0">" but same issue is happening.

Changed the (web vbproj) file and changed ToolSet Version to 14.0 from 12.0. Other vb projects part of the solution are still targeting 12.0 but gets compiled in dll as part of web vb project.


问:
Service instance parameters update in CF user provided service
I am new to Cloud Foundry and I have deployed local bosh-lite CF installation.

I have a Spring Boot with Hibernate JPA application which connects to postgresql which is again running locally which i want to deploy.

For this i created an user provided service for postgresql with service instance parameters of host,port,username and password.

Now i deployed the app and have bound the app to the service instance.

Now when i restart the app the app fails with some connection error (host name was wrong) to the db instance.
I changed the service instance parameters using cfups command to update the host parameters. The command returned 0 as response.

Now i restage the application to let the changes take effect. But the app again fails with the same error pointing to the old host parameter.

It seems  either the parameter changes did not take place using the cfups command or somehow the app is not getting restaged with the new parameters.

Another question how do i get to see the current service instance parameters of the already running service instance. ? cf service servicename only gives the name and the apps bound to it

UPDATE

I followed the tutorial here  https://www.youtube.com/watch?v=g3DbtW5lwqY by Scott Frederick and went with the third option i.e. to configure by having spring boot cloud connector and postgresql driver in my classpath.

So in bullett points my scenario

Deployed bosh-lite in Vagrant based Virtual Box Ubuntu

Installed Postgresql on host machine

Deployed my Spring Boot application configured with Spring boot cloud connector

Created a Postgresql CF service instance

Bound my application with the service instance

App cannot start and fails with connection refused error.

I checked the postgres instance in my local machine. On curl localhost:5432 it is running empty response that means it is working. I am even login using psql

Below is the output of my cf env app` . Host of service instance parameter "postgressql-service-instance1" is the ip of my host machine which has the postgresql isntalled. I am on a Vagrant based Virtual Box Ubuntu.

```<code>System-Provided:
{
 "VCAP_SERVICES": {
  "user-provided": [
   {
    "credentials": {
     "host": "10.0.2.2",
     "password": "admin",
     "port": "5432",
     "username": "postgres"
    },
    "label": "user-provided",
    "name": "postgresql-service-instance1",
    "syslog_drain_url": "",
    "tags": [],
    "volume_mounts": []
   }
  ]
 }
}

{
 "VCAP_APPLICATION": {
  "application_id": "194af4c6-5bbc-4644-af04-55cdaff12b6d",
  "application_name": "employeerest2",
  "application_uris": [
   "employeerest2.bosh-lite.com"
  ],
  "application_version": "facfce7e-9436-4059-94e8-3139172fa482",
  "cf_api": "https://api.bosh-lite.com",
  "limits": {
   "disk": 1024,
   "fds": 16384,
   "mem": 256
  },
  "name": "employeerest2",
  "space_id": "9a8b306d-8509-4241-b1fc-3ecb652c0733",
  "space_name": "development",
  "uris": [
   "employeerest2.bosh-lite.com"
  ],
  "users": null,
  "version": "facfce7e-9436-4059-94e8-3139172fa482"
 }
}

No user-defined env variables have been set

No running env variables have been set

No staging env variables have been set
</code>```

As you can see my app is bound to an service. But whenver i try to restart, restage the app i get the following error` Which clearly shows the connection is refused at localhost:5432. But i am not using localhost as a host service parameter to connect to.

I have configured my postgresql instance to accept connection from my guest OS. I don't know how Spring Boot is getting the host name as "localhost"

```<code>2017-06-01T21:51:55.74+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at org.postgresql.core.PGStream.<init>(PGStream.java:61) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.75+0530 [App/0] OUT     ... 53 common frames omitted
2017-06-01T21:51:55.75+0530 [App/0] OUT 2017-06-01 16:21:55.751 ERROR 29 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2017-06-01T21:51:55.76+0530 [App/0] OUT 2017-06-01 16:21:55.760  WARN 29 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2017-06-01T21:51:55.76+0530 [App/0] OUT 2017-06-01 16:21:55.765  INFO 29 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2017-06-01T21:51:55.78+0530 [App/0] OUT 2017-06-01 16:21:55.789  INFO 29 --- [           main] utoConfigurationReportLoggingInitializer :
2017-06-01T21:51:55.78+0530 [App/0] OUT Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-06-01T21:51:55.79+0530 [App/0] OUT 2017-06-01 16:21:55.794 ERROR 29 --- [           main] o.s.boot.SpringApplication               : Application startup failed
2017-06-01T21:51:55.79+0530 [App/0] OUT org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.saurav.cf.casestudy.employee.EmployeerestApplication.main(EmployeerestApplication.java:20) [classes/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [app/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [app/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [app/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) [app/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     ... 24 common frames omitted
2017-06-01T21:51:55.79+0530 [App/0] OUT Caused by: org.hibernate.exception.JDBCConnectionException: Unable to obtain JDBC Connection
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:115) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.ExtractionContextImpl.getJdbcConnection(ExtractionContextImpl.java:65) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:40) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.initializeSequences(DatabaseInformationImpl.java:64) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.<init>(DatabaseInformationImpl.java:60) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:80) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:475) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     ... 30 common frames omitted
2017-06-01T21:51:55.79+0530 [App/0] OUT Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:262) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:215) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.Driver.makeConnection(Driver.java:404) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.Driver.connect(Driver.java:272) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:735) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:667) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.ExtractionContextImpl.getJdbcConnection(ExtractionContextImpl.java:62) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     ... 37 common frames omitted
2017-06-01T21:51:55.79+0530 [App/0] OUT Caused by: java.net.ConnectException: Connection refused (Connection refused)
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_131]
2017-06-01T21:51:55.80+0530 [App/0] OUT     at org.postgresql.core.PGStream.<init>(PGStream.java:61) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.80+0530 [App/0] OUT     at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.80+0530 [App/0] OUT     ... 53 common frames omitted
2017-06-01T21:51:55.81+0530 [App/0] ERR
</code>```

Saurav

答:
ok...finally i was able to tie all loose threads on this topic.

Just to summarize the overall solution for other readers. For some more details you can visit here No unique service maching interface error in Spring Boot Cloud Foundry error

If you have a scenario where you want to have a spring boot application talk to a database (hosted in other machine) and then run the application from cloud foundry. Then follow some of the tips below.

Once you deploy your Spring Boot application and want to use Spring Boot cloud connector make sure you have all the proper dependencies in your classpath (spring-boot-cloud-connector and jar.
If you want to bind a service instance with the application .

Make sure the credentials adhere to this specification http://cloud.spring.io/spring-cloud-connectors/spring-cloud-cloud-foundry-connector.html#_postgresql

In the service instance parameters make sure you use the uri parameter not depend on the username and password to construct the uri

Make sure your database instance is actually running and you have created application service groups to allow outbound communication from your cloud foundry app. https://docs.cloudfoundry.org/concepts/asg.html#viewing

Steps 3 and 4 were the mistakes i made. Once corrected the application works fine.

Best Regards, Saurav

Body:
I am new to Cloud Foundry and I have deployed local bosh-lite CF installation.

I have a Spring Boot with Hibernate JPA application which connects to postgresql which is again running locally which i want to deploy.

For this i created an user provided service for postgresql with service instance parameters of host,port,username and password.

Now i deployed the app and have bound the app to the service instance.

Now when i restart the app the app fails with some connection error (host name was wrong) to the db instance.
I changed the service instance parameters using cfups command to update the host parameters. The command returned 0 as response.

Now i restage the application to let the changes take effect. But the app again fails with the same error pointing to the old host parameter.

It seems  either the parameter changes did not take place using the cfups command or somehow the app is not getting restaged with the new parameters.

Another question how do i get to see the current service instance parameters of the already running service instance. ? cf service servicename only gives the name and the apps bound to it

UPDATE

I followed the tutorial here  https://www.youtube.com/watch?v=g3DbtW5lwqY by Scott Frederick and went with the third option i.e. to configure by having spring boot cloud connector and postgresql driver in my classpath.

So in bullett points my scenario

Deployed bosh-lite in Vagrant based Virtual Box Ubuntu

Installed Postgresql on host machine

Deployed my Spring Boot application configured with Spring boot cloud connector

Created a Postgresql CF service instance

Bound my application with the service instance

App cannot start and fails with connection refused error.

I checked the postgres instance in my local machine. On curl localhost:5432 it is running empty response that means it is working. I am even login using psql

Below is the output of my cf env app` . Host of service instance parameter "postgressql-service-instance1" is the ip of my host machine which has the postgresql isntalled. I am on a Vagrant based Virtual Box Ubuntu.

System-Provided:
{
 "VCAP_SERVICES": {
  "user-provided": [
   {
    "credentials": {
     "host": "10.0.2.2",
     "password": "admin",
     "port": "5432",
     "username": "postgres"
    },
    "label": "user-provided",
    "name": "postgresql-service-instance1",
    "syslog_drain_url": "",
    "tags": [],
    "volume_mounts": []
   }
  ]
 }
}

{
 "VCAP_APPLICATION": {
  "application_id": "194af4c6-5bbc-4644-af04-55cdaff12b6d",
  "application_name": "employeerest2",
  "application_uris": [
   "employeerest2.bosh-lite.com"
  ],
  "application_version": "facfce7e-9436-4059-94e8-3139172fa482",
  "cf_api": "https://api.bosh-lite.com",
  "limits": {
   "disk": 1024,
   "fds": 16384,
   "mem": 256
  },
  "name": "employeerest2",
  "space_id": "9a8b306d-8509-4241-b1fc-3ecb652c0733",
  "space_name": "development",
  "uris": [
   "employeerest2.bosh-lite.com"
  ],
  "users": null,
  "version": "facfce7e-9436-4059-94e8-3139172fa482"
 }
}

No user-defined env variables have been set

No running env variables have been set

No staging env variables have been set

As you can see my app is bound to an service. But whenver i try to restart, restage the app i get the following error` Which clearly shows the connection is refused at localhost:5432. But i am not using localhost as a host service parameter to connect to.

I have configured my postgresql instance to accept connection from my guest OS. I don't know how Spring Boot is getting the host name as "localhost"

2017-06-01T21:51:55.74+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_131]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at org.postgresql.core.PGStream.<init>(PGStream.java:61) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.75+0530 [App/0] OUT     at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.75+0530 [App/0] OUT     ... 53 common frames omitted
2017-06-01T21:51:55.75+0530 [App/0] OUT 2017-06-01 16:21:55.751 ERROR 29 --- [           main] o.h.engine.jdbc.spi.SqlExceptionHelper   : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2017-06-01T21:51:55.76+0530 [App/0] OUT 2017-06-01 16:21:55.760  WARN 29 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2017-06-01T21:51:55.76+0530 [App/0] OUT 2017-06-01 16:21:55.765  INFO 29 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2017-06-01T21:51:55.78+0530 [App/0] OUT 2017-06-01 16:21:55.789  INFO 29 --- [           main] utoConfigurationReportLoggingInitializer :
2017-06-01T21:51:55.78+0530 [App/0] OUT Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-06-01T21:51:55.79+0530 [App/0] OUT 2017-06-01 16:21:55.794 ERROR 29 --- [           main] o.s.boot.SpringApplication               : Application startup failed
2017-06-01T21:51:55.79+0530 [App/0] OUT org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1081) ~[spring-context-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:856) ~[spring-context-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar!/:1.5.3.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.saurav.cf.casestudy.employee.EmployeerestApplication.main(EmployeerestApplication.java:20) [classes/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [app/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [app/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [app/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) [app/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:954) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:882) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:353) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:370) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:359) ~[spring-orm-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624) ~[spring-beans-4.3.8.RELEASE.jar!/:4.3.8.RELEASE]
2017-06-01T21:51:55.79+0530 [App/0] OUT     ... 24 common frames omitted
2017-06-01T21:51:55.79+0530 [App/0] OUT Caused by: org.hibernate.exception.JDBCConnectionException: Unable to obtain JDBC Connection
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:115) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.ExtractionContextImpl.getJdbcConnection(ExtractionContextImpl.java:65) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:40) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.initializeSequences(DatabaseInformationImpl.java:64) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.<init>(DatabaseInformationImpl.java:60) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:80) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:475) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     ... 30 common frames omitted
2017-06-01T21:51:55.79+0530 [App/0] OUT Caused by: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:262) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:215) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.Driver.makeConnection(Driver.java:404) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.postgresql.Driver.connect(Driver.java:272) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:735) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:667) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:482) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131) ~[tomcat-jdbc-8.5.14.jar!/:na]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at org.hibernate.tool.schema.extract.internal.ExtractionContextImpl.getJdbcConnection(ExtractionContextImpl.java:62) ~[hibernate-core-5.0.12.Final.jar!/:5.0.12.Final]
2017-06-01T21:51:55.79+0530 [App/0] OUT     ... 37 common frames omitted
2017-06-01T21:51:55.79+0530 [App/0] OUT Caused by: java.net.ConnectException: Connection refused (Connection refused)
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_131]
2017-06-01T21:51:55.79+0530 [App/0] OUT     at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_131]
2017-06-01T21:51:55.80+0530 [App/0] OUT     at org.postgresql.core.PGStream.<init>(PGStream.java:61) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.80+0530 [App/0] OUT     at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144) ~[postgresql-9.4.1212.jre7.jar!/:9.4.1212.jre7]
2017-06-01T21:51:55.80+0530 [App/0] OUT     ... 53 common frames omitted
2017-06-01T21:51:55.81+0530 [App/0] ERR

Saurav


问:
Spring Cloud Stream App that is both sink and source
Can I create Spring Boot Application which is Spring Cloud Stream App having both the bindings Sink and Source?</p>

答: A processor will pass the message from inbound queue to outbound queue with some transformation based on the binding. A processor will not act as a sink or source. What is the requirement for having both source and sink in one app. </p>


问:
put() takes at least 3 arguments (2 given)
This is my code in Views.py

```<code>class NotificationsViewSet(viewsets.ModelViewSet):
    permission_classes = [permissions.IsAuthenticated, TokenHasReadWriteScope]
    queryset = Notifications.objects.all()
    serializer_class = NotificationsSerializer
    filter_fields = ('status','task','survey_type',)

    def put(self, request, pk, format=None):
        notifications = self.get_object(pk)
        serializer = NotificationsSerializer(notifications, data=request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

    def delete(self, request, pk, format=None):
        notifications = self.get_object(pk)
        notifications.delete()
        return Response(status=status.HTTP_204_NO_CONTENT)
</code>```

When i try to use method PUT i got error put() takes at least 3 arguments (2 given). What is wrong with my code?

答:
```<code>def put(self, request, pk, format=None):
</code>```

It takes 3 arguments at the minimum. Like:

```<code>self.put(request, pk)
</code>```

self variable needs to be passed.

Alternatively,

```<code>put(self, request, pk)
</code>```

Or 4 arguments at the max,

```<code>self.put(request, pk, format)
</code>```

Body:
This is my code in Views.py

class NotificationsViewSet(viewsets.ModelViewSet):
    permission_classes = [permissions.IsAuthenticated, TokenHasReadWriteScope]
    queryset = Notifications.objects.all()
    serializer_class = NotificationsSerializer
    filter_fields = ('status','task','survey_type',)

    def put(self, request, pk, format=None):
        notifications = self.get_object(pk)
        serializer = NotificationsSerializer(notifications, data=request.data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data)
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

    def delete(self, request, pk, format=None):
        notifications = self.get_object(pk)
        notifications.delete()
        return Response(status=status.HTTP_204_NO_CONTENT)

When i try to use method PUT i got error put() takes at least 3 arguments (2 given). What is wrong with my code?

Body:
def put(self, request, pk, format=None):

It takes 3 arguments at the minimum. Like:

self.put(request, pk)

self variable needs to be passed.

Alternatively,

put(self, request, pk)

Or 4 arguments at the max,

self.put(request, pk, format)


问:
Error adding VectorAssembler to Spark ML Pipeline
Trying to add VectorAssembler to the GBT pipeline example and get an error the pipeline cannot find the features field. I'm bringing in a sample file instead of a libsvm so I needed to transform the feature set set.

Error:
Exception in thread "main" java.lang.IllegalArgumentException: Field "features" does not exist.

```<code> val df = sqlContext.read
  .format("com.databricks.spark.csv")
  .option("header", "true")
  .option("inferSchema", "true")
  .load("data/training_example.csv")

val sampleDF = df.sample(false,0.05,987897L)

val assembler = new VectorAssembler()
  .setInputCols(Array("val1","val2","val3",...,"valN"))
  .setOutputCol("features")

val labelIndexer = new StringIndexer()
  .setInputCol("label")
  .setOutputCol("indexedLabel")
  .fit(sampleDF)

val featureIndexer = new VectorIndexer()
  .setInputCol("features")
  .setOutputCol("indexedFeatures")
  .setMaxCategories(4)
  .fit(sampleDF)

val Array(trainingData, testData) = sampleDF.randomSplit(Array(0.7, 0.3))

val gbt = new GBTClassifier()
  .setLabelCol("indexedLabel")
  .setFeaturesCol("indexedFeatures")
  .setMaxIter(3)
  .setMaxDepth(5)

val pipeline = new Pipeline()
  .setStages(Array(assembler,labelIndexer,featureIndexer,gbt))

val model = pipeline.fit(trainingData)

val predictions = model.transform(testData)

predictions.show(10)
</code>```

答:
Documentation sample has features column from the beginning.

```<code>val data = sqlContext.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
</code>```

You must fit a DF having features column.So transform your original DF with VectorAssembler and give it as input.

Body:
Trying to add VectorAssembler to the GBT pipeline example and get an error the pipeline cannot find the features field. I'm bringing in a sample file instead of a libsvm so I needed to transform the feature set set.

Error:
Exception in thread "main" java.lang.IllegalArgumentException: Field "features" does not exist.

 val df = sqlContext.read
  .format("com.databricks.spark.csv")
  .option("header", "true")
  .option("inferSchema", "true")
  .load("data/training_example.csv")

val sampleDF = df.sample(false,0.05,987897L)

val assembler = new VectorAssembler()
  .setInputCols(Array("val1","val2","val3",...,"valN"))
  .setOutputCol("features")

val labelIndexer = new StringIndexer()
  .setInputCol("label")
  .setOutputCol("indexedLabel")
  .fit(sampleDF)

val featureIndexer = new VectorIndexer()
  .setInputCol("features")
  .setOutputCol("indexedFeatures")
  .setMaxCategories(4)
  .fit(sampleDF)

val Array(trainingData, testData) = sampleDF.randomSplit(Array(0.7, 0.3))

val gbt = new GBTClassifier()
  .setLabelCol("indexedLabel")
  .setFeaturesCol("indexedFeatures")
  .setMaxIter(3)
  .setMaxDepth(5)

val pipeline = new Pipeline()
  .setStages(Array(assembler,labelIndexer,featureIndexer,gbt))

val model = pipeline.fit(trainingData)

val predictions = model.transform(testData)

predictions.show(10)

Body:
Documentation sample has features column from the beginning.

val data = sqlContext.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")

You must fit a DF having features column.So transform your original DF with VectorAssembler and give it as input.


问:
Cannot convert complex<double> to double
I'm trying to fix a program that I found so it takes diferent values than the ones it has as a test to itself. The program should be able to take an array of values that respresent a mathematical function as a signal and the output should be the Fast Fourier Transform to that signal. Here is what I already have fixed in the code:

```<code>#include <complex>
#include <iostream>
#include <valarray>

#define fnc(x) (x)

const double PI = 3.141592653589793238460;

typedef std::valarray<double> CArray;

union{
    double d;
    int i;
}num,i;

void fft(CArray& x)
{
    const size_t N = x.size();
    if (N <= 1) return;

    // divide
    CArray even = x[std::slice(0, N/2, 2)];
    CArray  odd = x[std::slice(1, N/2, 2)];

    // conquer
    fft(even);
    fft(odd);

    // combine
    for (size_t k = 0; k < N/2; ++k)
    {
        double t = std::polar(1.0, -2 * PI * k / N) * odd[k];
        x[k    ] = even[k] + t;
        x[k+N/2] = even[k] - t;
    }
}
    //Complex f = 1.0 / sqrt(N);
    //for (unsigned int i = 0; i < N; i++)
    //  x[i] *= f;

int main()
{
    num.d=513;
    double test[num.i];
    for(i.i=1; i.i < num.i;++i.i)
        test[i.i] = (double)fnc(i.i);
    CArray data(test, num.d);

    // forward fft
    fft(data);

    std::cout << "fft" << std::endl;
    for (i.i = 0; i.i < num.i; ++i.i)
    {
        std::cout << data[i.i] << std::endl;
    }
    return 0;
}
</code>```

When I try to compile it ti shows me the nect

error: cannot convert 'std::complex' to 'double' in initialization|

on the 34th line, on the line marked in this part:

```<code>    for (size_t k = 0; k < N/2; ++k)
    {
        double t = std::polar(1.0, -2 * PI * k / N) * odd[k];
        x[k    ] = even[k] + t;
        x[k+N/2] = even[k] - t;
    }
</code>```

pesizaly this one:

```<code>        double t = std::polar(1.0, -2 * PI * k / N) * odd[k];
</code>```

If anyone could tell me how to fix it I would be very thakfully.
For better references this is the original code, in case anyone could tell me a better way to fix it so it mekes what I want.

```<code>#include <complex>
#include <iostream>
#include <valarray>

const double PI = 3.141592653589793238460;

typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;

// Cooley–Tukey FFT (in-place, divide-and-conquer)
// Higher memory requirements and redundancy although more intuitive
void fft(CArray& x)
{
    const size_t N = x.size();
    if (N <= 1) return;

    // divide
    CArray even = x[std::slice(0, N/2, 2)];
    CArray  odd = x[std::slice(1, N/2, 2)];

    // conquer
    fft(even);
    fft(odd);

    // combine
    for (size_t k = 0; k < N/2; ++k)
    {
        Complex t = std::polar(1.0, -2 * PI * k / N) * odd[k];
        x[k    ] = even[k] + t;
        x[k+N/2] = even[k] - t;
    }
}

// Cooley-Tukey FFT (in-place, breadth-first, decimation-in-frequency)
// Better optimized but less intuitive
// !!! Warning : in some cases this code make result different from not     optimased version above (need to fix bug)
// The bug is now fixed @2017/05/30
void fft(CArray &x)
{
    // DFT
    unsigned int N = x.size(), k = N, n;
    double thetaT = 3.14159265358979323846264338328L / N;
    Complex phiT = Complex(cos(thetaT), -sin(thetaT)), T;
    while (k > 1)
    {
        n = k;
        k >>= 1;
        phiT = phiT * phiT;
        T = 1.0L;
        for (unsigned int l = 0; l < k; l++)
        {
            for (unsigned int a = l; a < N; a += n)
            {
                unsigned int b = a + k;
                Complex t = x[a] - x[b];
                x[a] += x[b];
                x[b] = t * T;
            }
            T *= phiT;
        }
    }
    // Decimate
    unsigned int m = (unsigned int)log2(N);
    for (unsigned int a = 0; a < N; a++)
    {
        unsigned int b = a;
        // Reverse bits
        b = (((b & 0xaaaaaaaa) >> 1) | ((b & 0x55555555) << 1));
        b = (((b & 0xcccccccc) >> 2) | ((b & 0x33333333) << 2));
        b = (((b & 0xf0f0f0f0) >> 4) | ((b & 0x0f0f0f0f) << 4));
        b = (((b & 0xff00ff00) >> 8) | ((b & 0x00ff00ff) << 8));
        b = ((b >> 16) | (b << 16)) >> (32 - m);
        if (b > a)
        {
            Complex t = x[a];
            x[a] = x[b];
            x[b] = t;
        }
    }
    //// Normalize (This section make it not working correctly)
    //Complex f = 1.0 / sqrt(N);
    //for (unsigned int i = 0; i < N; i++)
    //  x[i] *= f;
}

// inverse fft (in-place)
void ifft(CArray& x)
{
    // conjugate the complex numbers
    x = x.apply(std::conj);

    // forward fft
    fft( x );

    // conjugate the complex numbers again
    x = x.apply(std::conj);

    // scale the numbers
    x /= x.size();
}

int main()
{
    const Complex test[] = { 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 };
    CArray data(test, 8);

    // forward fft
    fft(data);

    std::cout << "fft" << std::endl;
    for (int i = 0; i < 8; ++i)
    {
        std::cout << data[i] << std::endl;
    }

    // inverse fft
    ifft(data);

    std::cout << std::endl << "ifft" << std::endl;
    for (int i = 0; i < 8; ++i)
    {
        std::cout << data[i] << std::endl;
    }
    return 0;
}
</code>```

Ps. If anyone knows a better code for what I need I could also use it.

答: The error message is pretty explicit: std::polar returns a std::complex, not a double. Looking at the rest of the code, maybe just change the type of t?

Body:
I'm trying to fix a program that I found so it takes diferent values than the ones it has as a test to itself. The program should be able to take an array of values that respresent a mathematical function as a signal and the output should be the Fast Fourier Transform to that signal. Here is what I already have fixed in the code:

#include <complex>
#include <iostream>
#include <valarray>

#define fnc(x) (x)

const double PI = 3.141592653589793238460;

typedef std::valarray<double> CArray;

union{
    double d;
    int i;
}num,i;

void fft(CArray& x)
{
    const size_t N = x.size();
    if (N <= 1) return;

    // divide
    CArray even = x[std::slice(0, N/2, 2)];
    CArray  odd = x[std::slice(1, N/2, 2)];

    // conquer
    fft(even);
    fft(odd);

    // combine
    for (size_t k = 0; k < N/2; ++k)
    {
        double t = std::polar(1.0, -2 * PI * k / N) * odd[k];
        x[k    ] = even[k] + t;
        x[k+N/2] = even[k] - t;
    }
}
    //Complex f = 1.0 / sqrt(N);
    //for (unsigned int i = 0; i < N; i++)
    //  x[i] *= f;

int main()
{
    num.d=513;
    double test[num.i];
    for(i.i=1; i.i < num.i;++i.i)
        test[i.i] = (double)fnc(i.i);
    CArray data(test, num.d);

    // forward fft
    fft(data);

    std::cout << "fft" << std::endl;
    for (i.i = 0; i.i < num.i; ++i.i)
    {
        std::cout << data[i.i] << std::endl;
    }
    return 0;
}

When I try to compile it ti shows me the nect

error: cannot convert 'std::complex' to 'double' in initialization|

on the 34th line, on the line marked in this part:

    for (size_t k = 0; k < N/2; ++k)
    {
        double t = std::polar(1.0, -2 * PI * k / N) * odd[k];
        x[k    ] = even[k] + t;
        x[k+N/2] = even[k] - t;
    }

pesizaly this one:

        double t = std::polar(1.0, -2 * PI * k / N) * odd[k];

If anyone could tell me how to fix it I would be very thakfully.
For better references this is the original code, in case anyone could tell me a better way to fix it so it mekes what I want.

#include <complex>
#include <iostream>
#include <valarray>

const double PI = 3.141592653589793238460;

typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;

// Cooley–Tukey FFT (in-place, divide-and-conquer)
// Higher memory requirements and redundancy although more intuitive
void fft(CArray& x)
{
    const size_t N = x.size();
    if (N <= 1) return;

    // divide
    CArray even = x[std::slice(0, N/2, 2)];
    CArray  odd = x[std::slice(1, N/2, 2)];

    // conquer
    fft(even);
    fft(odd);

    // combine
    for (size_t k = 0; k < N/2; ++k)
    {
        Complex t = std::polar(1.0, -2 * PI * k / N) * odd[k];
        x[k    ] = even[k] + t;
        x[k+N/2] = even[k] - t;
    }
}

// Cooley-Tukey FFT (in-place, breadth-first, decimation-in-frequency)
// Better optimized but less intuitive
// !!! Warning : in some cases this code make result different from not     optimased version above (need to fix bug)
// The bug is now fixed @2017/05/30
void fft(CArray &x)
{
    // DFT
    unsigned int N = x.size(), k = N, n;
    double thetaT = 3.14159265358979323846264338328L / N;
    Complex phiT = Complex(cos(thetaT), -sin(thetaT)), T;
    while (k > 1)
    {
        n = k;
        k >>= 1;
        phiT = phiT * phiT;
        T = 1.0L;
        for (unsigned int l = 0; l < k; l++)
        {
            for (unsigned int a = l; a < N; a += n)
            {
                unsigned int b = a + k;
                Complex t = x[a] - x[b];
                x[a] += x[b];
                x[b] = t * T;
            }
            T *= phiT;
        }
    }
    // Decimate
    unsigned int m = (unsigned int)log2(N);
    for (unsigned int a = 0; a < N; a++)
    {
        unsigned int b = a;
        // Reverse bits
        b = (((b & 0xaaaaaaaa) >> 1) | ((b & 0x55555555) << 1));
        b = (((b & 0xcccccccc) >> 2) | ((b & 0x33333333) << 2));
        b = (((b & 0xf0f0f0f0) >> 4) | ((b & 0x0f0f0f0f) << 4));
        b = (((b & 0xff00ff00) >> 8) | ((b & 0x00ff00ff) << 8));
        b = ((b >> 16) | (b << 16)) >> (32 - m);
        if (b > a)
        {
            Complex t = x[a];
            x[a] = x[b];
            x[b] = t;
        }
    }
    //// Normalize (This section make it not working correctly)
    //Complex f = 1.0 / sqrt(N);
    //for (unsigned int i = 0; i < N; i++)
    //  x[i] *= f;
}

// inverse fft (in-place)
void ifft(CArray& x)
{
    // conjugate the complex numbers
    x = x.apply(std::conj);

    // forward fft
    fft( x );

    // conjugate the complex numbers again
    x = x.apply(std::conj);

    // scale the numbers
    x /= x.size();
}

int main()
{
    const Complex test[] = { 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 };
    CArray data(test, 8);

    // forward fft
    fft(data);

    std::cout << "fft" << std::endl;
    for (int i = 0; i < 8; ++i)
    {
        std::cout << data[i] << std::endl;
    }

    // inverse fft
    ifft(data);

    std::cout << std::endl << "ifft" << std::endl;
    for (int i = 0; i < 8; ++i)
    {
        std::cout << data[i] << std::endl;
    }
    return 0;
}

Ps. If anyone knows a better code for what I need I could also use it.


问:
Getting pivot table information within controller Laravel 5.4
my tables:

I have the following controller:

public function index($id){
  $user = User::find($id)->group()->id;
  $group = Group::with('files.urls')->findOrFail($user);
  $data ['group'] = $group;
  return view('upload.files', $data);
 }```
</div>
</div>
</p>

<p>Basically in $id - i have id of the user. $user variable should get group_id of that user and use that id in findOrFail function to retrieve group information.</p>

<p>Relationships:</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-html lang-html prettyprint-override"><code>class Group extends Model
{
 public function course(){
  return $this->belongsTo('App\Course');
 }
 public function user(){
  return $this->belongsToMany('App\User');
 }
 public function files(){
  return $this->hasMany('App\File');
 }
}

class User extends Authenticatable
{
    use Notifiable;

    protected $fillable = [
        'name', 'email', 'password', 'phone'
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];
    public function group(){
     $this->belongsToMany('App\Group');
    }
}</code>```

答:
Your relationships are ok.

I think your logic is not well because it's considering just one group for the user, but a user could have many groups.

You should consider retrieve all groups first then perform the rest of the logic.

```<code>$groups = App\User::find(1)->group()->get()->toArray();
$groups = array_column($groups, 'group');
$files = App\Files::select('urls')->whereIn('group_id', $groups);
</code>```

Edit.

Your group relationship in the User model doesn't have a return.

Body:
my tables:

I have the following controller:

public function index($id){
  $user = User::find($id)->group()->id;
  $group = Group::with('files.urls')->findOrFail($user);
  $data ['group'] = $group;
  return view('upload.files', $data);
 }

Basically in $id - i have id of the user. $user variable should get group_id of that user and use that id in findOrFail function to retrieve group information.

Relationships:

class Group extends Model
{
 public function course(){
  return $this->belongsTo('App\Course');
 }
 public function user(){
  return $this->belongsToMany('App\User');
 }
 public function files(){
  return $this->hasMany('App\File');
 }
}

class User extends Authenticatable
{
    use Notifiable;

    protected $fillable = [
        'name', 'email', 'password', 'phone'
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];
    public function group(){
     $this->belongsToMany('App\Group');
    }
}

Body:
Your relationships are ok.

I think your logic is not well because it's considering just one group for the user, but a user could have many groups.

You should consider retrieve all groups first then perform the rest of the logic.

$groups = App\User::find(1)->group()->get()->toArray();
$groups = array_column($groups, 'group');
$files = App\Files::select('urls')->whereIn('group_id', $groups);

Edit.

Your group relationship in the User model doesn't have a return.


问:
Laravel Form::Model Binding - PUT/PATCH Update Routing not working
I have routes set up to to create a person record as follows:

```<code>Route::get('bodymaker/create', 'BodyMakerController@create')->name('bodymaker.create');
Route::post('bodymaker', 'BodyMakerController@store')->name('bodymaker.store');
Route::get('bodymaker/{id}/edit', 'BodyMakerController@edit')->name('bodymaker.edit');
Route::put('bodymaker/{id}/update', 'BodyMakerController@update')->name('bodymaker.update');
Route::patch('bodymaker/{id}', 'BodyMakerController@update')->name('bodymaker.update');
</code>```

The controller methods to generate a new record works properly and look like this:

```<code>public function create()
{
    return View::make('bodymaker.create');
}

public function store(Request $request)
{
    $person = new Person;

    $person->first_name = $request->first_name;
    $person->last_name = $request->last_name;
    $person->save();

    return View::make('person.store', ['person'=>$person]);
}
</code>```

NOW... my problem is getting the edit/update form to bind properly...

```<code>public function edit($id)
{
    $person = Person::findOrFail($id);

    return View::make('person.edit', ['person'=>$person]);
}

public function update($id)
{
// This route fails when I pass in the Request $request like in the store method.
//But how does the update method receive the form values differently than the store method(?)
    $person = Person::findOrFail($id);

    $person->first_name = $request->first_name;
    $person->last_name = $request->last_name;
    $person->save();

    return View::make('person.update', ['person'=>$person]);
}
</code>```

The form for the update looks like this

```<code>{{ Form::model($person, ['route' => ['person.edit', $person->id], 'method' => 'PUT'] }}

        {{ csrf_field() }}
        {!!  Form::text('first_name'), Input::old('first_name')  !!}
        {!!  Form::text('last_name'), Input::old('last_name')  !!}
        {!! Form::submit('Update Person') !!}

{!!  Form::close()  !!}
</code>```

I can't seem to get the form to update the record, only been able to generate a new record.  Something about the syntax for the Form::model binding that I'm not understanding. The PUT request is failing when I pass in the Request as an argument so I don't understand the difference between POST & PUT as used inside Laravel either, though I'm not sure that's my problem

Here is my artisan route:list

```<code>| web,auth |||GET|HEAD| bodymaker/{id}/edit  | bodymaker.edit  | App\Http\Controllers\BodyMakerController@edit
| web,auth |||PUT     | bodymaker/{id}/update| bodymaker.update| App\Http\Controllers\BodyMakerController@update
</code>```

答:
You should set  method = "POST" of the form.And the in the form add {{method_filed('PUT')}} when use PUT method.

The same with others.

Body:
I have routes set up to to create a person record as follows:

Route::get('bodymaker/create', 'BodyMakerController@create')->name('bodymaker.create');
Route::post('bodymaker', 'BodyMakerController@store')->name('bodymaker.store');
Route::get('bodymaker/{id}/edit', 'BodyMakerController@edit')->name('bodymaker.edit');
Route::put('bodymaker/{id}/update', 'BodyMakerController@update')->name('bodymaker.update');
Route::patch('bodymaker/{id}', 'BodyMakerController@update')->name('bodymaker.update');

The controller methods to generate a new record works properly and look like this:

public function create()
{
    return View::make('bodymaker.create');
}

public function store(Request $request)
{
    $person = new Person;

    $person->first_name = $request->first_name;
    $person->last_name = $request->last_name;
    $person->save();

    return View::make('person.store', ['person'=>$person]);
}

NOW... my problem is getting the edit/update form to bind properly...

public function edit($id)
{
    $person = Person::findOrFail($id);

    return View::make('person.edit', ['person'=>$person]);
}

public function update($id)
{
// This route fails when I pass in the Request $request like in the store method.
//But how does the update method receive the form values differently than the store method(?)
    $person = Person::findOrFail($id);

    $person->first_name = $request->first_name;
    $person->last_name = $request->last_name;
    $person->save();

    return View::make('person.update', ['person'=>$person]);
}

The form for the update looks like this

{{ Form::model($person, ['route' => ['person.edit', $person->id], 'method' => 'PUT'] }}

        {{ csrf_field() }}
        {!!  Form::text('first_name'), Input::old('first_name')  !!}
        {!!  Form::text('last_name'), Input::old('last_name')  !!}
        {!! Form::submit('Update Person') !!}

{!!  Form::close()  !!}

I can't seem to get the form to update the record, only been able to generate a new record.  Something about the syntax for the Form::model binding that I'm not understanding. The PUT request is failing when I pass in the Request as an argument so I don't understand the difference between POST & PUT as used inside Laravel either, though I'm not sure that's my problem

Here is my artisan route:list

| web,auth |||GET|HEAD| bodymaker/{id}/edit  | bodymaker.edit  | App\Http\Controllers\BodyMakerController@edit
| web,auth |||PUT     | bodymaker/{id}/update| bodymaker.update| App\Http\Controllers\BodyMakerController@update


答:
std::complex<double> and double are incompatible types.

Change this:

```<code>double t = std::polar(1.0, -2 * PI * k / N) * odd[k];
</code>```

to this:

```<code>std::complex<double> t = std::polar(1.0, -2 * PI * k / N) * odd[k];
</code>```

since std::polar returns:

The complex cartesian equivalent to the polar format formed by rho and theta.

Title: Cannot convert complex<double> to double

Body:
std::complex<double> and double are incompatible types.

Change this:

double t = std::polar(1.0, -2 * PI * k / N) * odd[k];

to this:

std::complex<double> t = std::polar(1.0, -2 * PI * k / N) * odd[k];

since std::polar returns:

The complex cartesian equivalent to the polar format formed by rho and theta.


问:
Connecting to a Postgresql database running on host OS
i am running a postgresql instance in my host machine (Mac OS). I am able to access this instance by JDBC using localhost property in my Spring Boot application

Now i have a guest Ubuntu Virtual Box OS installed. and i want to install the same instance from this OS.

So i just changed the data source url of the same application from localhost to the host ip and port .
But now when i deploy the application and try to run it, i get "connection refused" error.

Telnet to host os from guest OS (10.0.2.2 5432) is working fine.

Content from my pg_hba.conf file

```<code>    # TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                md5
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5
host    all             all              0.0.0.0/0                       md5
host    all             all              ::/0                            md5
</code>```

Connections and authentications content from my postgresql.conf

```<code>    #------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'              # what IP address(es) to listen on;
                    # comma-separated list of addresses;
                    # defaults to 'localhost'; use '*' for all
                    # (change requires restart)
port = 5432             # (change requires restart)
max_connections = 100           # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '/tmp'   # comma-separated list of directories
                    # (change requires restart)
#unix_socket_group = ''         # (change requires restart)
#unix_socket_permissions = 0777     # begin with 0 to use octal notation
                    # (change requires restart)
#bonjour = off              # advertise server via Bonjour
                    # (change requires restart)
#bonjour_name = ''          # defaults to the computer name
                    # (change requires restart)
</code>```

So i have configured my postgrsql instance to accept connections from any IP.

i am behind a firewall.

Probably i am still missing somethings

Best Regards,
Saurav

答:
This was a problem with my configuration of Spring Boot and Cloud Foundry..it was nowhere related to Postgresql.

Curious readers please head over to No unique service maching interface error in Spring Boot Cloud Foundry error for the solution

ContentLicense: CC BY-SA 4.0

Body:
i am running a postgresql instance in my host machine (Mac OS). I am able to access this instance by JDBC using localhost property in my Spring Boot application

Now i have a guest Ubuntu Virtual Box OS installed. and i want to install the same instance from this OS.

So i just changed the data source url of the same application from localhost to the host ip and port .
But now when i deploy the application and try to run it, i get "connection refused" error.

Telnet to host os from guest OS (10.0.2.2 5432) is working fine.

Content from my pg_hba.conf file

    # TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                md5
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5
host    all             all              0.0.0.0/0                       md5
host    all             all              ::/0                            md5

Connections and authentications content from my postgresql.conf

    #------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'              # what IP address(es) to listen on;
                    # comma-separated list of addresses;
                    # defaults to 'localhost'; use '*' for all
                    # (change requires restart)
port = 5432             # (change requires restart)
max_connections = 100           # (change requires restart)
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directories = '/tmp'   # comma-separated list of directories
                    # (change requires restart)
#unix_socket_group = ''         # (change requires restart)
#unix_socket_permissions = 0777     # begin with 0 to use octal notation
                    # (change requires restart)
#bonjour = off              # advertise server via Bonjour
                    # (change requires restart)
#bonjour_name = ''          # defaults to the computer name
                    # (change requires restart)

So i have configured my postgrsql instance to accept connections from any IP.

i am behind a firewall.

Probably i am still missing somethings

Best Regards,
Saurav