问:
Using Generic swift enum in a protocol
I have case where I often scratch my head around, let's say I have a generic Manager class in a pod that can handle permission, and within the app, I want to be able to extend it to create more meaningful method name, aka to use with enum as parameter, to make its use more clear and less prone to mistake.

But it seems that you can't call private method when you create the extension elsewhere.

I'm sure there would be a more clean way with Generic/AssociatedValue or maybe my pattern is just wrong...

Here's the simplified version of it:

Class in the external pod:

```<code>public class FeatureDataManager {

    public static let shared = FeatureDataManager()

    private var permissionManager: PermissionManager!

    private init() {
        self.permissionManager = PermissionManager()
    }

    private getPermission(forFeature feature: String) -> Bool {
        return self.permissionManager.isEnable(feature)
    }
}
</code>```

and the extension in the app:

```<code>extension FeatureDataManager {
    enum FeatureType: String {
        case ads = "ads"
        case showBanner = "banner"
        case showFullScreenPub = "showFullScreenPub"
    }

    public func isPermissionEnable(forFeature feature: FeatureType) {
        // Does not compile, visibility issue
        self.getPermission(forFeature: feature.rawValue)
    }
}
</code>```

Clarification:

FeatureDataManager is a class in the Pod that is solely used to check for permissions in the form of String value across many app that are using importing it.

I wanted each single app using it, to define an extension that would have their own finite enum of their supported permissions. Let's say App A support Ads, but not App B. So I wanted to have a universal method that when you call featureManager.isPermissionEnable(.Ads), whenever app that is, the auto-complete would just offer the list of the supported permission for that app. Also, the goal of wrapping my string permission value into an enum is to be more bulletproof to mistake and easier refactoring if a name change, just have to change it in a single place.

答:
What you're looking for would be a "protected" level, and that doesn't exist in Swift, and can't exist without creating a new protection level, since it would break compiler optimizations. In your example, since getPermission(forFeature:) is promised never to be called outside this scope, the compiler is free to inline it. So this function may not even exist at the point that your extension wants to call it.

It would be possible for Swift to add a "protected" level that is "semi-public," but Swift does not have any such feature. You will need to redesign FeatureDataManager to make this possible. From your example, it's not obvious how to do that, because you provide no public interface for permissions at all, so it's not clear what you mean by "I want to be able to extend it to create more meaningful method name." Currently there is no public method name. If there were one, then making a more convenient syntax like you describe would be easy.

Can you give an example of the calling code that you want this extension to improve?

For more on why the language is this way, see Access Control and protected. It's not an accident.

You note that you can do this in the same file, and that's true. Swift allows this for stylistic reasons (many people use extensions inside a single file for code organization reasons). Swift treats all extensions in the same file as being in the main definition. But that does not extend to other files, and certainly not to other modules.

The generic solution to this looks like:

```<code>public class FeatureDataManager<Feature>
where Feature: RawRepresentable, Feature.RawValue == String {

    private func getPermission(forFeature feature: String) -> Bool { ... }

    public func isPermissionEnable(forFeature feature: Feature) {
        self.getPermission(forFeature: feature.rawValue)
    }
}
</code>```

An App would then create a feature set and create a manager for that feature set:

```<code>enum AppFeature: String {
    case ads = "ads"
    case showBanner = "banner"
    case showFullScreenPub = "showFullScreenPub"
}

let featureDataManager = FeatureDataManager<AppFeature>()
featureDataManager.isPermissionEnable(forFeature: .ads)
</code>```

That does prevent the easy creation of a .shared instance. It's arguable whether that's good or bad, but on the assumption that you want it, you would need to wrap it up:

```<code>class AppFeatureDataManager {
    enum Feature: String {
        case ads = "ads"
        case showBanner = "banner"
        case showFullScreenPub = "showFullScreenPub"
    }

    static var shared = AppFeatureDataManager()

    let manager = FeatureDataManager<Feature>()

    public func isPermissionEnable(forFeature feature: Feature) {
        manager.isPermissionEnable(forFeature: feature)
    }
}
</code>```

Now that's a bit too much boiler-plate for the app side (especially if there are more methods than isPermissionEnable), so you can remove the boilerplate this way (full code):

```<code>public class FeatureDataManager<Feature>
where Feature: RawRepresentable, Feature.RawValue == String {

    private var permissionManager: PermissionManager

    init() {
        self.permissionManager = PermissionManager()
    }

    private func getPermission(forFeature feature: String) -> Bool {
        self.permissionManager.isEnable(feature)
    }

    public func isPermissionEnable(forFeature feature: Feature) {
        self.getPermission(forFeature: feature.rawValue)
    }
}

protocol AppFeatureDataManager {
    associatedtype Feature: RawRepresentable where Feature.RawValue == String
    var manager: FeatureDataManager<Feature> { get }
}

// Here you can write any necessary pass-through functions so the app doesn't have to
extension AppFeatureDataManager {
    public func isPermissionEnable(forFeature feature: Feature) {
        manager.isPermissionEnable(forFeature: feature)
    }
}

//
// Application Developer writes this:
//
class MyGreatAppFeatureDataManager {
    enum Feature: String {
        case ads = "ads"
        case showBanner = "banner"
        case showFullScreenPub = "showFullScreenPub"
    }

    // This is the only thing that's really required
    let manager = FeatureDataManager<Feature>()

    // They're free make this a shared instance or not as they like.
    // That's not something the framework cares about.
    static var shared = MyGreatAppFeatureDataManager()
    private init() {}
}
</code>```

All that said, I think this is getting too many layers if FeatureDataManager is really just a front-end for PermissionManager like you've described here. (Maybe your example is highly simplified, so the below doesn't apply.)

If PermissionManager is public, and the real goal is just to have a nicer front-end to it, I would write it this way:

```<code>protocol FeatureDataManager {
    associatedtype Feature: RawRepresentable where Feature.RawValue == String
    var permissionManager: PermissionManager { get }
}

extension FeatureDataManager {
    func isPermissionEnable(forFeature feature: Feature) {
        permissionManager.isEnable(feature.rawValue)
    }
}

//
// App developer writes this
//
class MyGreatAppFeatureDataManager: FeatureDataManager {
    enum Feature: String {
        case ads = "ads"
        case showBanner = "banner"
        case showFullScreenPub = "showFullScreenPub"
    }

    // This is the only required boilerplate; the protocol can't do this for you.
    let permissionManager = PermissionManager()

    // And the developer can decide to make it a shared instance if they like,
    // but it's not the business of the framework
    static let shared = MyGreatAppFeatureDataManager()
    private init() {}
}
</code>```

Title: Using Generic swift enum in a protocol

Body:
I have case where I often scratch my head around, let's say I have a generic Manager class in a pod that can handle permission, and within the app, I want to be able to extend it to create more meaningful method name, aka to use with enum as parameter, to make its use more clear and less prone to mistake.

But it seems that you can't call private method when you create the extension elsewhere.

I'm sure there would be a more clean way with Generic/AssociatedValue or maybe my pattern is just wrong...

Here's the simplified version of it:

Class in the external pod:

public class FeatureDataManager {

    public static let shared = FeatureDataManager()

    private var permissionManager: PermissionManager!

    private init() {
        self.permissionManager = PermissionManager()
    }

    private getPermission(forFeature feature: String) -> Bool {
        return self.permissionManager.isEnable(feature)
    }
}

and the extension in the app:

extension FeatureDataManager {
    enum FeatureType: String {
        case ads = "ads"
        case showBanner = "banner"
        case showFullScreenPub = "showFullScreenPub"
    }

    public func isPermissionEnable(forFeature feature: FeatureType) {
        // Does not compile, visibility issue
        self.getPermission(forFeature: feature.rawValue)
    }
}

Clarification:

FeatureDataManager is a class in the Pod that is solely used to check for permissions in the form of String value across many app that are using importing it.

I wanted each single app using it, to define an extension that would have their own finite enum of their supported permissions. Let's say App A support Ads, but not App B. So I wanted to have a universal method that when you call featureManager.isPermissionEnable(.Ads), whenever app that is, the auto-complete would just offer the list of the supported permission for that app. Also, the goal of wrapping my string permission value into an enum is to be more bulletproof to mistake and easier refactoring if a name change, just have to change it in a single place.

Body:
What you're looking for would be a "protected" level, and that doesn't exist in Swift, and can't exist without creating a new protection level, since it would break compiler optimizations. In your example, since getPermission(forFeature:) is promised never to be called outside this scope, the compiler is free to inline it. So this function may not even exist at the point that your extension wants to call it.

It would be possible for Swift to add a "protected" level that is "semi-public," but Swift does not have any such feature. You will need to redesign FeatureDataManager to make this possible. From your example, it's not obvious how to do that, because you provide no public interface for permissions at all, so it's not clear what you mean by "I want to be able to extend it to create more meaningful method name." Currently there is no public method name. If there were one, then making a more convenient syntax like you describe would be easy.

Can you give an example of the calling code that you want this extension to improve?

For more on why the language is this way, see Access Control and protected. It's not an accident.

You note that you can do this in the same file, and that's true. Swift allows this for stylistic reasons (many people use extensions inside a single file for code organization reasons). Swift treats all extensions in the same file as being in the main definition. But that does not extend to other files, and certainly not to other modules.

The generic solution to this looks like:

public class FeatureDataManager<Feature>
where Feature: RawRepresentable, Feature.RawValue == String {

    private func getPermission(forFeature feature: String) -> Bool { ... }

    public func isPermissionEnable(forFeature feature: Feature) {
        self.getPermission(forFeature: feature.rawValue)
    }
}

An App would then create a feature set and create a manager for that feature set:

enum AppFeature: String {
    case ads = "ads"
    case showBanner = "banner"
    case showFullScreenPub = "showFullScreenPub"
}

let featureDataManager = FeatureDataManager<AppFeature>()
featureDataManager.isPermissionEnable(forFeature: .ads)

That does prevent the easy creation of a .shared instance. It's arguable whether that's good or bad, but on the assumption that you want it, you would need to wrap it up:

class AppFeatureDataManager {
    enum Feature: String {
        case ads = "ads"
        case showBanner = "banner"
        case showFullScreenPub = "showFullScreenPub"
    }

    static var shared = AppFeatureDataManager()

    let manager = FeatureDataManager<Feature>()

    public func isPermissionEnable(forFeature feature: Feature) {
        manager.isPermissionEnable(forFeature: feature)
    }
}

Now that's a bit too much boiler-plate for the app side (especially if there are more methods than isPermissionEnable), so you can remove the boilerplate this way (full code):

public class FeatureDataManager<Feature>
where Feature: RawRepresentable, Feature.RawValue == String {

    private var permissionManager: PermissionManager

    init() {
        self.permissionManager = PermissionManager()
    }

    private func getPermission(forFeature feature: String) -> Bool {
        self.permissionManager.isEnable(feature)
    }

    public func isPermissionEnable(forFeature feature: Feature) {
        self.getPermission(forFeature: feature.rawValue)
    }
}

protocol AppFeatureDataManager {
    associatedtype Feature: RawRepresentable where Feature.RawValue == String
    var manager: FeatureDataManager<Feature> { get }
}

// Here you can write any necessary pass-through functions so the app doesn't have to
extension AppFeatureDataManager {
    public func isPermissionEnable(forFeature feature: Feature) {
        manager.isPermissionEnable(forFeature: feature)
    }
}

//
// Application Developer writes this:
//
class MyGreatAppFeatureDataManager {
    enum Feature: String {
        case ads = "ads"
        case showBanner = "banner"
        case showFullScreenPub = "showFullScreenPub"
    }

    // This is the only thing that's really required
    let manager = FeatureDataManager<Feature>()

    // They're free make this a shared instance or not as they like.
    // That's not something the framework cares about.
    static var shared = MyGreatAppFeatureDataManager()
    private init() {}
}

All that said, I think this is getting too many layers if FeatureDataManager is really just a front-end for PermissionManager like you've described here. (Maybe your example is highly simplified, so the below doesn't apply.)

If PermissionManager is public, and the real goal is just to have a nicer front-end to it, I would write it this way:

protocol FeatureDataManager {
    associatedtype Feature: RawRepresentable where Feature.RawValue == String
    var permissionManager: PermissionManager { get }
}

extension FeatureDataManager {
    func isPermissionEnable(forFeature feature: Feature) {
        permissionManager.isEnable(feature.rawValue)
    }
}

//
// App developer writes this
//
class MyGreatAppFeatureDataManager: FeatureDataManager {
    enum Feature: String {
        case ads = "ads"
        case showBanner = "banner"
        case showFullScreenPub = "showFullScreenPub"
    }

    // This is the only required boilerplate; the protocol can't do this for you.
    let permissionManager = PermissionManager()

    // And the developer can decide to make it a shared instance if they like,
    // but it's not the business of the framework
    static let shared = MyGreatAppFeatureDataManager()
    private init() {}
}


来源: stackexchange

问:
ERROR: Minimum supported Gradle version is 5.6.4. Current version is 5.2.1
It builds ok but when I try to run it I get the following errors:

```<code>Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.internal.version-check']

Caused by: java.lang.RuntimeException: Minimum supported Gradle version is 5.6.4. Current version is 5.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\chris.russo\Documents\Temp\Socket401\Socket401\app\gradle\wrapper\gradle-wrapper.properties to gradle-5.6.4-all.zip

ERROR: Minimum supported Gradle version is 5.6.4. Current version is 5.2.1.
Please fix the project's Gradle settings.
Fix Gradle wrapper and re-import project
Open Gradle wrapper properties
Gradle settings
</code>```

The link for "Fix gradle wrapper and re-import project" does nothing

The gradle-wrapper properties file reads:

```<code>#Wed May 27 14:58:40 MDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
</code>```

Under project structure, I have configured the gradle version to 5.6.4.

I have tried updating the tool, invalidating the cache, and uninstalling and reinstalling the tool. Nothing seems to be fixing this.

答:
I ended up resolving the issue by downloading the complete version of 5.6.4 directly from the website: https://gradle.org/releases/.  I then copied the folder into the android program files directory and linked the tool to it by doing:

File
-Settings
-Build, Excecution, Deployment
-Gradle

Under "use gradle from" I selected specified location and pointed to the file I downloaded.

Thanks to all for you help!

ContentLicense: CC BY-SA 4.0

Body:
It builds ok but when I try to run it I get the following errors:

Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.internal.version-check']

Caused by: java.lang.RuntimeException: Minimum supported Gradle version is 5.6.4. Current version is 5.2.1. If using the gradle wrapper, try editing the distributionUrl in C:\Users\chris.russo\Documents\Temp\Socket401\Socket401\app\gradle\wrapper\gradle-wrapper.properties to gradle-5.6.4-all.zip

ERROR: Minimum supported Gradle version is 5.6.4. Current version is 5.2.1.
Please fix the project's Gradle settings.
Fix Gradle wrapper and re-import project
Open Gradle wrapper properties
Gradle settings

The link for "Fix gradle wrapper and re-import project" does nothing

The gradle-wrapper properties file reads:

#Wed May 27 14:58:40 MDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

Under project structure, I have configured the gradle version to 5.6.4.

I have tried updating the tool, invalidating the cache, and uninstalling and reinstalling the tool. Nothing seems to be fixing this.


问:
Prove a function is surjective using Z3
I'm trying to understand how to prove efficiently using Z3 that a somewhat simple function f : u32 -> u32 is bijective:

def f(n):
    for i in range(10):
        n *= 3
        n &= 0xFFFFFFFF # Let's treat this like a 4 byte unsigned number
        n ^= 0xDEADBEEF
    return n
```

<p>I know already it is bijective since it's obtained by composition of bijective functions, so this is more of a computational question.</p>

<p>Now, knowing the domain and codomain are finite and of the same size, I thought of first doing this by asking Z3 to find a counterexample to it being injective:</p>

<pre class="lang-py prettyprint-override"><code>N = BitVec('N', 32)
M = BitVec('M', 32)
solve(N != M, f(N) == f(M))
</code>```

However this is taking quite a while (> 10 minutes but shut it down after), and reasonably so, since the search space is pretty much 64 bit and the function may be quite complex to reason about since it mixes a lot of multiplication with binary arithmetic, so I wondered whether it was possible instead to prove it by surjection, maybe resulting faster.

Whether that's actually faster or if there's even a way to solve this efficiently yet may be another question, however I was stuck on thinking how to prove it by surjection, that is ask Z3 to find an M such that f(N) != M forall N.

Is this anywhere different from proving injectivity?

How do I state it in Z3's python bindings?

Is it possible to remove existential qualifiers out of the surjective statement at all?

Are there more efficient ways to prove that a function is bijective? Since for something like this a bruteforce search may be more efficient, as the memory required shouldn't be a lot for 32 bit vectors, but the approach surely wouldn't work on 64 bit input/outputs.

答:
You'd write the surjectivity as follows:

N = BitVec('N', 32)
M = BitVec('M', 32)
s = Solver()
s.add(ForAll([N], f(N) != M))

r = s.check()
if r == sat:
    print(s.model())
else:
    print(r)
```

<p>Unfortunately adding quantifiers to bit-vectors make the logic undecidable in general, and z3 simply gives up after about 10 seconds on my machine:</p>

```unknown
```

<p>In general, adding quantifiers is just going to make the problem very difficult for z3 (or any other SMT solver for that matter). Your original encoding of:</p>

```solve(N!=M, f(N) == f(M))
```

is probably the best way to encode this problem. And in fact, if you change the range from 10 to something smaller (I tried up-to 3), z3 answers unsat relatively quickly. But obviously the solver time will go exponentially as the number of iterations in your function f increases.

An SMT solver is probably not the best tool to prove a property like this. You can surely express such constraints, but at best you'll get unknown as an answer and at worst it'll loop forever. A proper theorem prover (like Isabelle, HOL, Coq, ACL2, etc.) would provide a much better (at the cost of being less automated) platform to do these proofs.

Title: Prove a function is surjective using Z3

Body:
I'm trying to understand how to prove efficiently using Z3 that a somewhat simple function f : u32 -> u32 is bijective:

def f(n):
    for i in range(10):
        n *= 3
        n &= 0xFFFFFFFF # Let's treat this like a 4 byte unsigned number
        n ^= 0xDEADBEEF
    return n

I know already it is bijective since it's obtained by composition of bijective functions, so this is more of a computational question.

Now, knowing the domain and codomain are finite and of the same size, I thought of first doing this by asking Z3 to find a counterexample to it being injective:

N = BitVec('N', 32)
M = BitVec('M', 32)
solve(N != M, f(N) == f(M))

However this is taking quite a while (> 10 minutes but shut it down after), and reasonably so, since the search space is pretty much 64 bit and the function may be quite complex to reason about since it mixes a lot of multiplication with binary arithmetic, so I wondered whether it was possible instead to prove it by surjection, maybe resulting faster.

Whether that's actually faster or if there's even a way to solve this efficiently yet may be another question, however I was stuck on thinking how to prove it by surjection, that is ask Z3 to find an M such that f(N) != M forall N.

Is this anywhere different from proving injectivity?

How do I state it in Z3's python bindings?

Is it possible to remove existential qualifiers out of the surjective statement at all?

Are there more efficient ways to prove that a function is bijective? Since for something like this a bruteforce search may be more efficient, as the memory required shouldn't be a lot for 32 bit vectors, but the approach surely wouldn't work on 64 bit input/outputs.

Body:
You'd write the surjectivity as follows:

N = BitVec('N', 32)
M = BitVec('M', 32)
s = Solver()
s.add(ForAll([N], f(N) != M))

r = s.check()
if r == sat:
    print(s.model())
else:
    print(r)

Unfortunately adding quantifiers to bit-vectors make the logic undecidable in general, and z3 simply gives up after about 10 seconds on my machine:

unknown

In general, adding quantifiers is just going to make the problem very difficult for z3 (or any other SMT solver for that matter). Your original encoding of:

solve(N!=M, f(N) == f(M))

is probably the best way to encode this problem. And in fact, if you change the range from 10 to something smaller (I tried up-to 3), z3 answers unsat relatively quickly. But obviously the solver time will go exponentially as the number of iterations in your function f increases.

An SMT solver is probably not the best tool to prove a property like this. You can surely express such constraints, but at best you'll get unknown as an answer and at worst it'll loop forever. A proper theorem prover (like Isabelle, HOL, Coq, ACL2, etc.) would provide a much better (at the cost of being less automated) platform to do these proofs.


问:
How to deploy Node Media Server app on heroku
I am trying to deploy a NodeJS live streaming server which works on heroku built on rtmp server using node-media-server and socket.io. I am facing issue in starting the node-media-server since it needs 2 ports to run as per config format:

```<code>const NodeMediaServer = require('node-media-server');

const config = {
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 30,
    ping_timeout: 60
  },
  http: {
    port: 8000,
    allow_origin: '*'
  }
};

var nms = new NodeMediaServer(config)
nms.run();
</code>```

I've tried deploying app on new heroku app by following official guide. Since Heroku provides only one port per dyno, it gives me these logs on my heroku app dashboard:

```<code>2020-04-07T23:08:24.289041+00:00 app[web.1]: 4/7/2020 23:08:24 23 [ERROR] Node Media Trans Server startup failed. ffmpeg:/usr/local/bin/ffmpeg cannot be executed.
2020-04-07T23:08:24.290753+00:00 app[web.1]: (node:23) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-04-07T23:08:24.291397+00:00 app[web.1]: listening on port 19586
2020-04-07T23:08:24.292059+00:00 app[web.1]: 4/7/2020 23:08:24 23 [ERROR] Node Media Rtmp Server Error: listen EADDRINUSE: address already in use :::19586
2020-04-07T23:08:24.292694+00:00 app[web.1]: 4/7/2020 23:08:24 23 [ERROR] Node Media Http Server Error: listen EADDRINUSE: address already in use :::19586
2020-04-07T23:08:24.293383+00:00 app[web.1]: 4/7/2020 23:08:24 23 [ERROR] Node Media WebSocket Server Error: listen EADDRINUSE: address already in use :::19586
2020-04-07T23:08:24.682440+00:00 heroku[web.1]: State changed from starting to up
2020-04-07T23:08:24.693405+00:00 app[web.1]: Connected to the database
</code>```

I need to know how I can deploy my app on heroku (or any other alternative) to make it available in production mode. My server works fine on my MacBook Pro.
Here's my code:

```<code>const { NodeMediaServer } = require('node-media-server');
const express = require('express');
const mongoose = require('mongoose');

const app = express();
const http = require('http');
const fs = require('fs');
const bodyParser = require('body-parser');
const path = require('path');
const process = require('process')
const port = process.env.PORT||5000
const port2 = process.env.PORT||8000
const port3 = process.env.PORT||8001

const server = http.createServer(app);
const io = require('socket.io').listen(server);
require('./app/controllers/socketIO')(io);

mongoose.Promise = global.Promise;
global.appRoot = path.resolve(__dirname);

mongoose.connect(
  "mongodb://databasecredentials",
  { useNewUrlParser: true },
  err => {
    if (err) {
      console.log(err);
    } else {
      console.log('Connected to the database');
    }
  }
);

app.use(
  bodyParser.urlencoded({
    extended: true
  })
);
app.use(bodyParser.json());
app.set('socketio', io);
app.set('server', server);
app.use(express.static(`${__dirname}/public`));

server.listen(port, err => {
  if (err) {
    console.log(err);
  } else {
    console.log(`listening on port ${port}`);
  }
});

const nodeMediaServerConfig = {
  rtmp: {
    port: port2,
    chunk_size: 60000,
    gop_cache: true,
    ping: 60,
    ping_timeout: 30
  },
  http: {
    port: port3,
    mediaroot: './media',
    allow_origin: '*'
  },
  trans: {
    ffmpeg: '/usr/local/bin/ffmpeg',
    tasks: [
      {
        app: 'live',
        ac: 'aac',
        mp4: true,
        mp4Flags: '[movflags=faststart]'
      }
    ]
  }
};

var nms = new NodeMediaServer(nodeMediaServerConfig);
nms.run();
</code>```

答:
I'm not very familiar with Heroku, but in the first line of the logs it states:

[ERROR] Node Media Trans Server startup failed. ffmpeg:/usr/local/bin/ffmpeg cannot be executed.

you need to install ffmpeg on the machine running the code. This is the first step to get your server starting (this might not fix all the problems you're having but this is the first thing you need to start with).
 I'm trying to do something similar using GCP. In order to get it to run, I created a package.json file and set the start script to apt install --fix-missing --assume-yes ffmpeg && node app.js as a temporary workaround:

```<code>{
    "name": "app-service-hello-world",
    "description": "Simple Hello World Node.js sample for Azure App Service",
    "version": "0.0.1",
    "private": true,
    "license": "MIT",
    "author": "Microsoft",
    "scripts": {
        "start": "apt install --fix-missing --assume-yes ffmpeg && node app.js"
    },
    "dependencies": {
        "node-media-server": "^2.1.9"
    }
}
</code>```

This might help you adding ffmpeg correctly to your Heroku environment: Install FFMPEG on Heroku

Body:
I am trying to deploy a NodeJS live streaming server which works on heroku built on rtmp server using node-media-server and socket.io. I am facing issue in starting the node-media-server since it needs 2 ports to run as per config format:

const NodeMediaServer = require('node-media-server');

const config = {
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 30,
    ping_timeout: 60
  },
  http: {
    port: 8000,
    allow_origin: '*'
  }
};

var nms = new NodeMediaServer(config)
nms.run();

I've tried deploying app on new heroku app by following official guide. Since Heroku provides only one port per dyno, it gives me these logs on my heroku app dashboard:

2020-04-07T23:08:24.289041+00:00 app[web.1]: 4/7/2020 23:08:24 23 [ERROR] Node Media Trans Server startup failed. ffmpeg:/usr/local/bin/ffmpeg cannot be executed.
2020-04-07T23:08:24.290753+00:00 app[web.1]: (node:23) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
2020-04-07T23:08:24.291397+00:00 app[web.1]: listening on port 19586
2020-04-07T23:08:24.292059+00:00 app[web.1]: 4/7/2020 23:08:24 23 [ERROR] Node Media Rtmp Server Error: listen EADDRINUSE: address already in use :::19586
2020-04-07T23:08:24.292694+00:00 app[web.1]: 4/7/2020 23:08:24 23 [ERROR] Node Media Http Server Error: listen EADDRINUSE: address already in use :::19586
2020-04-07T23:08:24.293383+00:00 app[web.1]: 4/7/2020 23:08:24 23 [ERROR] Node Media WebSocket Server Error: listen EADDRINUSE: address already in use :::19586
2020-04-07T23:08:24.682440+00:00 heroku[web.1]: State changed from starting to up
2020-04-07T23:08:24.693405+00:00 app[web.1]: Connected to the database

I need to know how I can deploy my app on heroku (or any other alternative) to make it available in production mode. My server works fine on my MacBook Pro.
Here's my code:

const { NodeMediaServer } = require('node-media-server');
const express = require('express');
const mongoose = require('mongoose');

const app = express();
const http = require('http');
const fs = require('fs');
const bodyParser = require('body-parser');
const path = require('path');
const process = require('process')
const port = process.env.PORT||5000
const port2 = process.env.PORT||8000
const port3 = process.env.PORT||8001

const server = http.createServer(app);
const io = require('socket.io').listen(server);
require('./app/controllers/socketIO')(io);

mongoose.Promise = global.Promise;
global.appRoot = path.resolve(__dirname);

mongoose.connect(
  "mongodb://databasecredentials",
  { useNewUrlParser: true },
  err => {
    if (err) {
      console.log(err);
    } else {
      console.log('Connected to the database');
    }
  }
);

app.use(
  bodyParser.urlencoded({
    extended: true
  })
);
app.use(bodyParser.json());
app.set('socketio', io);
app.set('server', server);
app.use(express.static(`${__dirname}/public`));

server.listen(port, err => {
  if (err) {
    console.log(err);
  } else {
    console.log(`listening on port ${port}`);
  }
});

const nodeMediaServerConfig = {
  rtmp: {
    port: port2,
    chunk_size: 60000,
    gop_cache: true,
    ping: 60,
    ping_timeout: 30
  },
  http: {
    port: port3,
    mediaroot: './media',
    allow_origin: '*'
  },
  trans: {
    ffmpeg: '/usr/local/bin/ffmpeg',
    tasks: [
      {
        app: 'live',
        ac: 'aac',
        mp4: true,
        mp4Flags: '[movflags=faststart]'
      }
    ]
  }
};

var nms = new NodeMediaServer(nodeMediaServerConfig);
nms.run();

Body:
I'm not very familiar with Heroku, but in the first line of the logs it states:

[ERROR] Node Media Trans Server startup failed. ffmpeg:/usr/local/bin/ffmpeg cannot be executed.

you need to install ffmpeg on the machine running the code. This is the first step to get your server starting (this might not fix all the problems you're having but this is the first thing you need to start with).
 I'm trying to do something similar using GCP. In order to get it to run, I created a package.json file and set the start script to apt install --fix-missing --assume-yes ffmpeg && node app.js as a temporary workaround:

{
    "name": "app-service-hello-world",
    "description": "Simple Hello World Node.js sample for Azure App Service",
    "version": "0.0.1",
    "private": true,
    "license": "MIT",
    "author": "Microsoft",
    "scripts": {
        "start": "apt install --fix-missing --assume-yes ffmpeg && node app.js"
    },
    "dependencies": {
        "node-media-server": "^2.1.9"
    }
}

This might help you adding ffmpeg correctly to your Heroku environment: Install FFMPEG on Heroku


问:
How to print the " symbol in python
How do I print " symbol in python.

My code: print(f"{filefolder}" ", uid, " f"{usergroup}" " mode, " f"{permissions}" f"{capability}" f"{contexts}")

For example one of the outputs: acct, uid, 0000 0000 mode, 0755 u:object_r:cgroup:s0

But I need say, uid to be "uid". I've tried adding the "" around uid, but I get a syntax error.

答:
Use a backslash:

```<code>print("text: \" ")
</code>```

gives
text: "

Title: How to print the " symbol in python

Body:
Use a backslash:

print("text: \" ")

gives
text: "


问:
Limit the date to today and block the previous dates
I am beginner in JavaScript, I know the subject exists on StackOverFlow as here below but I don't understand.

Compare two dates with JavaScript

I would like to handle the previous dates for example: We are on 28-05-2020, if the user enters on 27-05-2020 an error message should appear.

For information, I am obliged to use JavaScript to handle the dates.

function validation()
{
    const date_start = document.getElementById('date_start').value;
    const inputDate = new Date(date_start);

    const dayFromImputDate = inputDate.getFullYear(); // previous day

    const now = new Date();
    const dateNow = now.getFullYear();

    if(dayFromImputDatee < dateNow) {
        document.getElementById('date_startError').innerHTML = " ** Error date ! ";
        return false;
    }

    if(date_start == ""){
        document.getElementById('date_startError').innerHTML = " ** date empty ! ";
        return false;
    }

    console.log("Date is valid");
    return true;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="fr">
<head>
  <meta charset="utf-8">
  <title>Titre de la page</title>
  <link rel="stylesheet" href="style.css">
  <script src="script.js"></script>
</head>
<body>
<form action="#" onsubmit="return validation()" >
<br>
<label>Date start : </label>
<br>
<input type="date" name="date_start" id="date_start">
<br>
<span id="date_startError"></span>
<br>
<input type="submit" value="ok">
</form>
</body>
</html></code>```

Thank you very much for your help and your time.

答:
If I understand the problem correctly you are trying to restrict a date form input to the current day or some future date.
To check whether a date is valid you could do this:</p>

```<code>    let earliestPossibleDate = new Date(
        now.getFullYear(), now.getMonth(), now.getDate()
    );
    let isValidDate = date_start >= earliestPossibleDate
</code>```

Body:
I am beginner in JavaScript, I know the subject exists on StackOverFlow as here below but I don't understand.

Compare two dates with JavaScript

I would like to handle the previous dates for example: We are on 28-05-2020, if the user enters on 27-05-2020 an error message should appear.

For information, I am obliged to use JavaScript to handle the dates.

function validation()
{
    const date_start = document.getElementById('date_start').value;
    const inputDate = new Date(date_start);

    const dayFromImputDate = inputDate.getFullYear(); // previous day

    const now = new Date();
    const dateNow = now.getFullYear();

    if(dayFromImputDatee < dateNow) {
        document.getElementById('date_startError').innerHTML = " ** Error date ! ";
        return false;
    }

    if(date_start == ""){
        document.getElementById('date_startError').innerHTML = " ** date empty ! ";
        return false;
    }

    console.log("Date is valid");
    return true;
}

<!DOCTYPE html>

  <meta charset="utf-8">
  <title>Titre de la page</title>
  <link rel="stylesheet" href="style.css">

<form action="#" onsubmit="return validation()" >

Date start :

<input type="date" name="date_start" id="date_start">

<input type="submit" value="ok">
</form>

Thank you very much for your help and your time.

Body:
If I understand the problem correctly you are trying to restrict a date form input to the current day or some future date.
To check whether a date is valid you could do this:

    let earliestPossibleDate = new Date(
        now.getFullYear(), now.getMonth(), now.getDate()
    );
    let isValidDate = date_start >= earliestPossibleDate


问:
H2 embeded DB with spring boot error auto configuring
i'm trying to use the H2 embedded DB with spring boot. But, it throws the following errors.

```2016-10-19 22:05:25.818  INFO 14104 --- [           main] com.example.SpringDemoApplication        : Starting SpringDemoApplication on BOM1-LPMP12AS7U with PID 14104 (D:\workspace\eclipse\SpringDemo\target\classes started by e3028311 in D:\workspace\eclipse\SpringDemo)
2016-10-19 22:05:25.822  INFO 14104 --- [           main] com.example.SpringDemoApplication        : No active profile set, falling back to default profiles: default
2016-10-19 22:05:25.904  INFO 14104 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@543e710e: startup date [Wed Oct 19 22:05:25 IST 2016]; root of context hierarchy
2016-10-19 22:05:27.609  INFO 14104 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$ece75ca4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-10-19 22:05:28.474  INFO 14104 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-10-19 22:05:28.490  INFO 14104 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-10-19 22:05:28.491  INFO 14104 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.37
2016-10-19 22:05:28.658  INFO 14104 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-10-19 22:05:28.658  INFO 14104 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2759 ms
2016-10-19 22:05:29.055  INFO 14104 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-10-19 22:05:29.060  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2016-10-19 22:05:29.131  WARN 14104 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
2016-10-19 22:05:29.146  INFO 14104 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2016-10-19 22:05:29.169 ERROR 14104 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1218) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at com.example.SpringDemoApplication.main(SpringDemoApplication.java:27) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 26 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1199) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1123) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1021) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 28 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 40 common frames omitted
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:180) ~[spring-boot-autoconfigure-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:121) ~[spring-boot-autoconfigure-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_91]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 41 common frames omitted

2016-10-19 22:05:29.173  INFO 14104 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/D:/workspace/eclipse/SpringDemo/target/classes/, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.3.8.RELEASE/spring-boot-starter-web-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.8.RELEASE/spring-boot-starter-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot/1.3.8.RELEASE/spring-boot-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.8.RELEASE/spring-boot-autoconfigure-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.8.RELEASE/spring-boot-starter-logging-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar, file:/C:/Users/e3028311/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.3.8.RELEASE/spring-boot-starter-tomcat-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.37/tomcat-embed-core-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.37/tomcat-embed-el-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.37/tomcat-embed-logging-juli-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.37/tomcat-embed-websocket-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-validation/1.3.8.RELEASE/spring-boot-starter-validation-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar, file:/C:/Users/e3028311/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/classmate/1.1.0/classmate-1.1.0.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.7/jackson-databind-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.7/jackson-annotations-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.7/jackson-core-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-web/4.2.8.RELEASE/spring-web-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-aop/4.2.8.RELEASE/spring-aop-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-beans/4.2.8.RELEASE/spring-beans-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-context/4.2.8.RELEASE/spring-context-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-webmvc/4.2.8.RELEASE/spring-webmvc-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-expression/4.2.8.RELEASE/spring-expression-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-core/4.2.8.RELEASE/spring-core-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/1.3.8.RELEASE/spring-boot-starter-data-jpa-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-aop/1.3.8.RELEASE/spring-boot-starter-aop-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.11.Final/hibernate-entitymanager-4.3.11.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.jar, file:/C:/Users/e3028311/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar, file:/C:/Users/e3028311/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar, file:/C:/Users/e3028311/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/data/spring-data-jpa/1.9.5.RELEASE/spring-data-jpa-1.9.5.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/data/spring-data-commons/1.11.5.RELEASE/spring-data-commons-1.11.5.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-orm/4.2.8.RELEASE/spring-orm-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-tx/4.2.8.RELEASE/spring-tx-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-aspects/4.2.8.RELEASE/spring-aspects-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.3.8.RELEASE/spring-boot-starter-jdbc-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.0.37/tomcat-jdbc-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/tomcat-juli/8.0.37/tomcat-juli-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-jdbc/4.2.8.RELEASE/spring-jdbc-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/com/h2database/h2/1.4.192/h2-1.4.192.jar]
```

<p>Below is my POM </p>

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

    <groupId>com.example</groupId>
    <artifactId>SpringDemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

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

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

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

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

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

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

</project>
```

<p>Below is my main class</p>

```package com.example;

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

@SpringBootApplication
@EnableAutoConfiguration
public class SpringDemoApplication {

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

    }

}
```

Previously, I had problems running even simple Spring boot application on my eclipse. But, worked fine on IntelliJ. Then I installed Spring Suite on Eclipse, after which embedded tomcat started working. But now, Database configuration is having problems. Please assist. Where am I going wrong?

Please view the Structure here.

答:
If the above Solution are not working in Your case
Try the below in application.properties</p>

```<code>                  spring.h2.console.enabled=true
                  spring.datasource.platform=h2
                  spring.jpa.show-sql=true
</code>```

ContentLicense: CC BY-SA 3.0

Body:
i'm trying to use the H2 embedded DB with spring boot. But, it throws the following errors.

2016-10-19 22:05:25.818  INFO 14104 --- [           main] com.example.SpringDemoApplication        : Starting SpringDemoApplication on BOM1-LPMP12AS7U with PID 14104 (D:\workspace\eclipse\SpringDemo\target\classes started by e3028311 in D:\workspace\eclipse\SpringDemo)
2016-10-19 22:05:25.822  INFO 14104 --- [           main] com.example.SpringDemoApplication        : No active profile set, falling back to default profiles: default
2016-10-19 22:05:25.904  INFO 14104 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@543e710e: startup date [Wed Oct 19 22:05:25 IST 2016]; root of context hierarchy
2016-10-19 22:05:27.609  INFO 14104 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$ece75ca4] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-10-19 22:05:28.474  INFO 14104 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-10-19 22:05:28.490  INFO 14104 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2016-10-19 22:05:28.491  INFO 14104 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.37
2016-10-19 22:05:28.658  INFO 14104 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2016-10-19 22:05:28.658  INFO 14104 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2759 ms
2016-10-19 22:05:29.055  INFO 14104 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2016-10-19 22:05:29.060  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-10-19 22:05:29.061  INFO 14104 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2016-10-19 22:05:29.131  WARN 14104 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
2016-10-19 22:05:29.146  INFO 14104 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2016-10-19 22:05:29.169 ERROR 14104 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1218) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:760) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:360) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:306) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at com.example.SpringDemoApplication.main(SpringDemoApplication.java:27) [classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 26 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1127) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1022) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1199) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1123) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1021) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 28 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 40 common frames omitted
Caused by: org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:180) ~[spring-boot-autoconfigure-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:121) ~[spring-boot-autoconfigure-1.3.8.RELEASE.jar:1.3.8.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_91]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.2.8.RELEASE.jar:4.2.8.RELEASE]
    ... 41 common frames omitted

2016-10-19 22:05:29.173  INFO 14104 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/D:/workspace/eclipse/SpringDemo/target/classes/, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-web/1.3.8.RELEASE/spring-boot-starter-web-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter/1.3.8.RELEASE/spring-boot-starter-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot/1.3.8.RELEASE/spring-boot-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.3.8.RELEASE/spring-boot-autoconfigure-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.3.8.RELEASE/spring-boot-starter-logging-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar, file:/C:/Users/e3028311/.m2/repository/ch/qos/logback/logback-core/1.1.7/logback-core-1.1.7.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/jul-to-slf4j/1.7.21/jul-to-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.21/log4j-over-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/yaml/snakeyaml/1.16/snakeyaml-1.16.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/1.3.8.RELEASE/spring-boot-starter-tomcat-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/8.0.37/tomcat-embed-core-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/8.0.37/tomcat-embed-el-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-logging-juli/8.0.37/tomcat-embed-logging-juli-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/8.0.37/tomcat-embed-websocket-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-validation/1.3.8.RELEASE/spring-boot-starter-validation-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-validator/5.2.4.Final/hibernate-validator-5.2.4.Final.jar, file:/C:/Users/e3028311/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/classmate/1.1.0/classmate-1.1.0.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.6.7/jackson-databind-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.6.7/jackson-annotations-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.6.7/jackson-core-2.6.7.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-web/4.2.8.RELEASE/spring-web-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-aop/4.2.8.RELEASE/spring-aop-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-beans/4.2.8.RELEASE/spring-beans-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-context/4.2.8.RELEASE/spring-context-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-webmvc/4.2.8.RELEASE/spring-webmvc-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-expression/4.2.8.RELEASE/spring-expression-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-core/4.2.8.RELEASE/spring-core-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/1.3.8.RELEASE/spring-boot-starter-data-jpa-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-aop/1.3.8.RELEASE/spring-boot-starter-aop-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/aspectj/aspectjweaver/1.8.9/aspectjweaver-1.8.9.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.11.Final/hibernate-entitymanager-4.3.11.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/logging/jboss-logging/3.3.0.Final/jboss-logging-3.3.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.jar, file:/C:/Users/e3028311/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar, file:/C:/Users/e3028311/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar, file:/C:/Users/e3028311/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar, file:/C:/Users/e3028311/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar, file:/C:/Users/e3028311/.m2/repository/javax/transaction/javax.transaction-api/1.2/javax.transaction-api-1.2.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/data/spring-data-jpa/1.9.5.RELEASE/spring-data-jpa-1.9.5.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/data/spring-data-commons/1.11.5.RELEASE/spring-data-commons-1.11.5.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-orm/4.2.8.RELEASE/spring-orm-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-tx/4.2.8.RELEASE/spring-tx-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.21/jcl-over-slf4j-1.7.21.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-aspects/4.2.8.RELEASE/spring-aspects-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/1.3.8.RELEASE/spring-boot-starter-jdbc-1.3.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/tomcat-jdbc/8.0.37/tomcat-jdbc-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/apache/tomcat/tomcat-juli/8.0.37/tomcat-juli-8.0.37.jar, file:/C:/Users/e3028311/.m2/repository/org/springframework/spring-jdbc/4.2.8.RELEASE/spring-jdbc-4.2.8.RELEASE.jar, file:/C:/Users/e3028311/.m2/repository/com/h2database/h2/1.4.192/h2-1.4.192.jar]

Below is my POM

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

    <groupId>com.example</groupId>
    <artifactId>SpringDemo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

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

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

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

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

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

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

</project>

Below is my main class

package com.example;

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

@SpringBootApplication
@EnableAutoConfiguration
public class SpringDemoApplication {

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

    }

}

Previously, I had problems running even simple Spring boot application on my eclipse. But, worked fine on IntelliJ. Then I installed Spring Suite on Eclipse, after which embedded tomcat started working. But now, Database configuration is having problems. Please assist. Where am I going wrong?

Please view the Structure here.

Body:
If the above Solution are not working in Your case
Try the below in application.properties

                  spring.h2.console.enabled=true
                  spring.datasource.platform=h2
                  spring.jpa.show-sql=true


问:
Odoo select all records where user is follower
Can somebody give me example (or hint) how to select all records where user is follower?
I cant find any information about handling followers. What the condition should be?</p>

```<code>find_record = self.env['my_class'].search([( **user is floower** )])
</code>```

答:
try the following

first element of the tuple : the partner id related to the user

2nd element of the tuple : the logical operator 'in'

3rd element of the tuple : the id of partners following the record

```<code>self.env['helpdesk.ticket'].search([(self.env.user.partner_id.id, 'in', 'message_follower_ids.partner_id')])
</code>```

Body:
Can somebody give me example (or hint) how to select all records where user is follower?
I cant find any information about handling followers. What the condition should be?

find_record = self.env['my_class'].search([( **user is floower** )])

Body:
try the following

first element of the tuple : the partner id related to the user

2nd element of the tuple : the logical operator 'in'

3rd element of the tuple : the id of partners following the record

self.env['helpdesk.ticket'].search([(self.env.user.partner_id.id, 'in', 'message_follower_ids.partner_id')])


问:
Convert Plotly image byte object to numpy array

The plotly.io.to_image function is used to return an image as a
  bytes object (Doc).

I want to convert this byte object representing a PNG image, to numpy array so it can be used in Folium as image overlay.

Here is an example:

```<code>import plotly.graph_objects as go
# Create plot
fig = go.Figure(data =
    go.Contour(
        z=[[10, 10.625, 12.5, 15.625, 20],
           [5.625, 6.25, 8.125, 11.25, 15.625],
           [2.5, 3.125, 5., 8.125, 12.5],
           [0.625, 1.25, 3.125, 6.25, 10.625],
           [0, 0.625, 2.5, 5.625, 10]]
    ))
# Export byte object
img_bytes = fig.to_image(format="png",width=600, height=350)
</code>```

I have tried using PIL:

```<code>from PIL import Image
img = Image.frombytes("RGB", (350,600), img_bytes)
</code>```

Getting ValueError: not enough image data.

I have never used byte object before making this process very confusing for me.

PS: Any other way to use plotly figure on folium map is also appreciated.

答:
Got a working answer at Plotly Forums:

This is the function that converts Plotly fig image to an array:

```<code>import io
from PIL import Image

def plotly_fig2array(fig):
    #convert Plotly fig to  an array
    fig_bytes = fig.to_image(format="png")
    buf = io.BytesIO(fig_bytes)
    img = Image.open(buf)
    return np.asarray(img)

</code>```

Body:
The plotly.io.to_image function is used to return an image as a
  bytes object (Doc).

I want to convert this byte object representing a PNG image, to numpy array so it can be used in Folium as image overlay.

Here is an example:

import plotly.graph_objects as go
# Create plot
fig = go.Figure(data =
    go.Contour(
        z=[[10, 10.625, 12.5, 15.625, 20],
           [5.625, 6.25, 8.125, 11.25, 15.625],
           [2.5, 3.125, 5., 8.125, 12.5],
           [0.625, 1.25, 3.125, 6.25, 10.625],
           [0, 0.625, 2.5, 5.625, 10]]
    ))
# Export byte object
img_bytes = fig.to_image(format="png",width=600, height=350)

I have tried using PIL:

from PIL import Image
img = Image.frombytes("RGB", (350,600), img_bytes)

Getting ValueError: not enough image data.

I have never used byte object before making this process very confusing for me.

PS: Any other way to use plotly figure on folium map is also appreciated.

Body:
Got a working answer at Plotly Forums:

This is the function that converts Plotly fig image to an array:

import io
from PIL import Image

def plotly_fig2array(fig):
    #convert Plotly fig to  an array
    fig_bytes = fig.to_image(format="png")
    buf = io.BytesIO(fig_bytes)
    img = Image.open(buf)
    return np.asarray(img)


答:
I think you made a bit of a mess with the string interpolation, format seems cleaner:</p>

```<code>print('{filefolder}, "{uid}"'.format(filefolder=filfolder, uid=uid))
</code>```

Title: How to print the " symbol in python

Body:
How do I print " symbol in python.

My code: print(f"{filefolder}" ", uid, " f"{usergroup}" " mode, " f"{permissions}" f"{capability}" f"{contexts}")

For example one of the outputs: acct, uid, 0000 0000 mode, 0755 u:object_r:cgroup:s0

But I need say, uid to be "uid". I've tried adding the "" around uid, but I get a syntax error.

Body:
I think you made a bit of a mess with the string interpolation, format seems cleaner:

print('{filefolder}, "{uid}"'.format(filefolder=filfolder, uid=uid))