问:
How to solve Pymodbus exception when Master requests for holding registry values of the Arduino Slave
I currently trying to receive data from my Arduino slave to my computer. I am successful in creating an Arduino slave. However, when I am trying to receive the data from my computer using the Pymodbus library, my code fails to receive the data from the Arduino and raises a ModbusIOException. For the specifications of my project, I am trying to build a Modbus RTU with the Arduino to simulate a sensor with random numbers as readings. The Arduino code uses the Modbus-Arduino library of Andre Sarmento.

https://github.com/andresarmento/modbus-arduino

I already checked my Arduino slave if it is working. I tried reading the data through a Modbus Master emulator (QModMaster), and it worked just fine. This might prove that the problem itself is from the code for the Master. Furthermore, the serial connection seems to work fine, since the self.client.connect() returns True.

These are the screenshots of the QModMaster configurations.

Slave configurations
Serial Port configurations

Python code for the master:

```<code>class ModbusRTU:
    def __init__(self, graph_name, port, baudrate=9600,
                 stopbits=1, bytesize=8, parity='N',
                 timeout=1):
        self.graph_name = graph_name
        self.client = ModbusSerialClient(method='rtu',
                                         port=port,
                                         baudrate=baudrate,
                                         parity=parity,
                                         timeout=timeout)
        self.connection = self.client.connect()
        result = self.client.read_holding_registers(address=0,
                                                  count=2,
                                                  unit=1)
        print(result.registers)

if __name__ == '__main__':
    modbus = ModbusRTU(graph_name='/dev/ttyACM0',
                       port='/dev/ttyACM0', baudrate=9600,
                       stopbits=1, bytesize=8, parity='N',
                       timeout=1)
    print(modbus.check_connection())
</code>```

Arduino code for the simulated slave and sensor:

```<code>#include <Modbus.h>
#include <ModbusSerial.h>

ModbusSerial mb;
const int READING = 0;
const int DECIMAL = 1;

void setup() {
  mb.config(&Serial, 9600, SERIAL_8N1);
  mb.setSlaveId(1);
  mb.addHreg(READING);
  mb.addHreg(DECIMAL);
}

void loop() {
  mb.task();
  mb.Hreg(READING, random(1, 201));
  mb.Hreg(DECIMAL, random(0, 4));
}
</code>```

Upon printing the results.registers, it is supposedly a list of integers. However, it just raises a ModbusIOException with a message of:

```<code>'ModbusIOException' object has no attribute 'registers'
  File "/home/kebaranas/PythonProjects/ThirsyWell/tools/utilities.py", line 21, in __init__
    print(result.registers)
  File "/home/kebaranas/PythonProjects/ThirsyWell/tools/utilities.py", line 29, in <module>
    timeout=1)
</code>```

It also gives this message as well.

```<code>Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)
</code>```

答:
You're defining holding registers in your slave but you're trying to read them as input registers, try changing this line:

```<code>result = self.client.read_input_registers(address=1, count=2, unit=1)
</code>```

To:

```<code>result = self.client.read_holding_registers(address=1, count=2, unit=1)
</code>```

Be aware that the Modbus spec defines this two different types of registers: holding and input, depending on the memory region they are placed in.

Body:
I currently trying to receive data from my Arduino slave to my computer. I am successful in creating an Arduino slave. However, when I am trying to receive the data from my computer using the Pymodbus library, my code fails to receive the data from the Arduino and raises a ModbusIOException. For the specifications of my project, I am trying to build a Modbus RTU with the Arduino to simulate a sensor with random numbers as readings. The Arduino code uses the Modbus-Arduino library of Andre Sarmento.

https://github.com/andresarmento/modbus-arduino

I already checked my Arduino slave if it is working. I tried reading the data through a Modbus Master emulator (QModMaster), and it worked just fine. This might prove that the problem itself is from the code for the Master. Furthermore, the serial connection seems to work fine, since the self.client.connect() returns True.

These are the screenshots of the QModMaster configurations.

Slave configurations
Serial Port configurations

Python code for the master:

class ModbusRTU:
    def __init__(self, graph_name, port, baudrate=9600,
                 stopbits=1, bytesize=8, parity='N',
                 timeout=1):
        self.graph_name = graph_name
        self.client = ModbusSerialClient(method='rtu',
                                         port=port,
                                         baudrate=baudrate,
                                         parity=parity,
                                         timeout=timeout)
        self.connection = self.client.connect()
        result = self.client.read_holding_registers(address=0,
                                                  count=2,
                                                  unit=1)
        print(result.registers)

if __name__ == '__main__':
    modbus = ModbusRTU(graph_name='/dev/ttyACM0',
                       port='/dev/ttyACM0', baudrate=9600,
                       stopbits=1, bytesize=8, parity='N',
                       timeout=1)
    print(modbus.check_connection())

Arduino code for the simulated slave and sensor:

#include <Modbus.h>
#include <ModbusSerial.h>

ModbusSerial mb;
const int READING = 0;
const int DECIMAL = 1;

void setup() {
  mb.config(&Serial, 9600, SERIAL_8N1);
  mb.setSlaveId(1);
  mb.addHreg(READING);
  mb.addHreg(DECIMAL);
}

void loop() {
  mb.task();
  mb.Hreg(READING, random(1, 201));
  mb.Hreg(DECIMAL, random(0, 4));
}

Upon printing the results.registers, it is supposedly a list of integers. However, it just raises a ModbusIOException with a message of:

'ModbusIOException' object has no attribute 'registers'
  File "/home/kebaranas/PythonProjects/ThirsyWell/tools/utilities.py", line 21, in __init__
    print(result.registers)
  File "/home/kebaranas/PythonProjects/ThirsyWell/tools/utilities.py", line 29, in <module>
    timeout=1)

It also gives this message as well.

Modbus Error: [Input/Output] Modbus Error: [Invalid Message] Incomplete message received, expected at least 2 bytes (0 received)

Body:
You're defining holding registers in your slave but you're trying to read them as input registers, try changing this line:

result = self.client.read_input_registers(address=1, count=2, unit=1)

To:

result = self.client.read_holding_registers(address=1, count=2, unit=1)

Be aware that the Modbus spec defines this two different types of registers: holding and input, depending on the memory region they are placed in.


来源: stackexchange

问:
Filtering pandas dataframe by date to count views for timeline of programs
I need to count viewers by program for a streaming channel from a json logfile.
I identify the programs by their starttimes, such as:

So far I have two Dataframes like this:

The first one contains all the timestamps from the logfile

```<code>viewers_from_log = pd.read_json('sqllog.json', encoding='UTF-8')
# Convert date string to pandas datetime object:
viewers_from_log['time'] = pd.to_datetime(viewers_from_log['time'])
</code>```

Source JSON file:

```<code>[
    {
        "logid": 191605,
        "time": "0:00:17"
    },
    {
        "logid": 191607,
        "time": "0:00:26"
    },
    {
        "logid": 191611,
        "time": "0:01:20"
    }
]
</code>```

The second contains the starting times and titles of the programs

```<code>programs_start_time = pd.DataFrame.from_dict('programs.json', orient='index')
</code>```

Source JSON file:

```<code>{
    "2019-05-29": [
        {
            "title": "\"Amiről a kövek mesélnek\"",
            "startTime_dt": "2019-05-29T00:00:40Z"
        },
        {
            "title": "Koffer - Kedvcsináló Kul(t)túrák Külföldön",
            "startTime_dt": "2019-05-29T00:22:44Z"
        },
        {
            "title": "Gubancok",
            "startTime_dt": "2019-05-29T00:48:08Z"
        }
    ]
}
</code>```

So what I need to do is to count the entries / program in the log file and link them to the program titles.

答:
A working (but maybe a little quick and dirty) method:

Use the .shift(-1) method on the timestamp column of programs_start_time dataframe, to get an additional column with a name date_end indicating the timestamp of end for each TV program.

Then for each example_timestamp in the log file, you can query the TV programs dataframe like this: df[(df['date_start']=<example_timestamp) & (df['date_end']>example_timestamp)] (make sure you substitute df with your dataframe's name: programs_start_time) which will give you exactly one dataframe row and extract from it the name of the TV programm.

Hope this helps!

ContentLicense: CC BY-SA 4.0

Body:
I need to count viewers by program for a streaming channel from a json logfile.
I identify the programs by their starttimes, such as:

So far I have two Dataframes like this:

The first one contains all the timestamps from the logfile

viewers_from_log = pd.read_json('sqllog.json', encoding='UTF-8')
# Convert date string to pandas datetime object:
viewers_from_log['time'] = pd.to_datetime(viewers_from_log['time'])

Source JSON file:

[
    {
        "logid": 191605,
        "time": "0:00:17"
    },
    {
        "logid": 191607,
        "time": "0:00:26"
    },
    {
        "logid": 191611,
        "time": "0:01:20"
    }
]

The second contains the starting times and titles of the programs

programs_start_time = pd.DataFrame.from_dict('programs.json', orient='index')

Source JSON file:

{
    "2019-05-29": [
        {
            "title": "\"Amiről a kövek mesélnek\"",
            "startTime_dt": "2019-05-29T00:00:40Z"
        },
        {
            "title": "Koffer - Kedvcsináló Kul(t)túrák Külföldön",
            "startTime_dt": "2019-05-29T00:22:44Z"
        },
        {
            "title": "Gubancok",
            "startTime_dt": "2019-05-29T00:48:08Z"
        }
    ]
}

So what I need to do is to count the entries / program in the log file and link them to the program titles.


问:
How to synchronize database files between multiple clients on node.js server without download those files that are already downloaded?
I'm making a node.js application with a MySQL database, and there are string fields in some tables that represent paths in the filesystem for example: "C:\Users\steve\Desktop\my-nodejs-app\files\Apple.jpg" and when a client connects to the server for the first time automatically download all the files in those paths in the database. Every client can add registers and send files in the server.

My question is:
Let's suppose that two clients use the app regularly and client1 adds a new file in the files folder. In the client1's folder it will be all the files updated, but then client2 connects in the app and it has all the files but doesn't have the new file added.

How can I fix this? Make an app where a client just download those files that don't have and don't download all the files every time it connects to the server?

答: I'd suggest having the client request a list of all files on "connect", then loop through them to see if they exist locally.  If they don't, request/download them from the server.</p>


问:
in powershell, set affinity in start-process
In powershell, I can launch a process with

```<code>$app_name = "app.exe"
$app_arguments = "arg0"
Start-Process $app_name $app_arguments
</code>```

I try set the affinity with

```<code>$app = Start-Process $app_name $app_arguments
$app.ProcessorAffinity = 0x3
</code>```

.... no work.

In windows powershell, when I launch a process how I can set the affinity ?

答:
You need to pass -PassThru switch in order to get process object

```<code>$app = Start-Process $app_name $app_arguments -PassThru
$app.ProcessorAffinity = 0x3
</code>```

according to powershell Start-Process command (from ps 3.0)

-PassThru Returns a process object for each process that the cmdlet started. By default, this cmdlet does not generate any output.

ContentLicense: CC BY-SA 3.0

Body:
In powershell, I can launch a process with

$app_name = "app.exe"
$app_arguments = "arg0"
Start-Process $app_name $app_arguments

I try set the affinity with

$app = Start-Process $app_name $app_arguments
$app.ProcessorAffinity = 0x3

.... no work.

In windows powershell, when I launch a process how I can set the affinity ?

Body:
You need to pass -PassThru switch in order to get process object

$app = Start-Process $app_name $app_arguments -PassThru
$app.ProcessorAffinity = 0x3

according to powershell Start-Process command (from ps 3.0)

-PassThru Returns a process object for each process that the cmdlet started. By default, this cmdlet does not generate any output.


问:
How can I delete multipe lines in a text by Python?
I have a similar question to delete multiple line

I want to delete the line and the next 4 lines. This is my code:

```<code>bind = open('/etc/bind/named.conf.local','r')
a = dict['name']
for line in bind:
        if a in line:
            print('line  exist')
            ''' and delete this line and 4 line after it'''
        else:
            print('line does not exist')
</code>```

I want to save modify text in /etc/bind/named.conf.local in place, without fileinput. I do not want skip 4 line I want to delete them from the file. I do not want to read it and write it again and skip 4 lines.

What should I do?

答:
It all boils down to keeping a skip count that you initialize with the first occurrence of the matching line and increase afterward:

```<code>match = "text line to match"
with open('input.txt','r') as lines:
    with open('output.txt','w') as output:
        skip = -1
        for line in lines:
            skip += skip >= 0 or skip < 0 and line.strip("\n") == match
            if skip not in range(5):
                output.write(line)
</code>```

If what you're trying to avoid is reading lines one by one, you could write it like this (but you still need to open the files)

```<code>match    = "text line to match"
lines    = open('input.txt','r').read().split("\n")
matchPos = lines.index(match)
del lines[matchPos:matchPos+5]
open('output.txt','w').write("\n".join(lines))
</code>```

Body:
I have a similar question to delete multiple line

I want to delete the line and the next 4 lines. This is my code:

bind = open('/etc/bind/named.conf.local','r')
a = dict['name']
for line in bind:
        if a in line:
            print('line  exist')
            ''' and delete this line and 4 line after it'''
        else:
            print('line does not exist')

I want to save modify text in /etc/bind/named.conf.local in place, without fileinput. I do not want skip 4 line I want to delete them from the file. I do not want to read it and write it again and skip 4 lines.

What should I do?

Body:
It all boils down to keeping a skip count that you initialize with the first occurrence of the matching line and increase afterward:

match = "text line to match"
with open('input.txt','r') as lines:
    with open('output.txt','w') as output:
        skip = -1
        for line in lines:
            skip += skip >= 0 or skip < 0 and line.strip("\n") == match
            if skip not in range(5):
                output.write(line)

If what you're trying to avoid is reading lines one by one, you could write it like this (but you still need to open the files)

match    = "text line to match"
lines    = open('input.txt','r').read().split("\n")
matchPos = lines.index(match)
del lines[matchPos:matchPos+5]
open('output.txt','w').write("\n".join(lines))


问:
Laravel Auth return to index
Can I redirect to the previous page someone if not logged in? Also, is it possible to create a hierarchy system for users?

I tried this:

```<code>if(!(Auth::check())) {
            header("Location: {{ route('cooperado.index') }});
}
</code>```

But i not even got an error message, just doesn't work. I'm starting at laravel so it's kind of hard to fully understand how it works.

答:
Using Constructor in controller

You also can use middleware in order to redirect unauthenticated user back or somewhere else.

```<code>public method __construct(){
    $this->middleware('auth');
}
</code>```

Add this code in your controller so all methods within particular controller

-direct from route defination

```<code>Route::get('/path/',controller@method)->name('cooperado.index')->middleware('auth');
</code>```

Redirection

using this method unauthenticated user will redirect to login page.
in order to edit redirection page you can change '@redirectTo' method
in

app/Http/Middleware/Authenticate.php

file.

Title: Laravel Auth return to index

Body:
Can I redirect to the previous page someone if not logged in? Also, is it possible to create a hierarchy system for users?

I tried this:

if(!(Auth::check())) {
            header("Location: {{ route('cooperado.index') }});
}

But i not even got an error message, just doesn't work. I'm starting at laravel so it's kind of hard to fully understand how it works.

Body:
Using Constructor in controller

You also can use middleware in order to redirect unauthenticated user back or somewhere else.

public method __construct(){
    $this->middleware('auth');
}

Add this code in your controller so all methods within particular controller

-direct from route defination

Route::get('/path/',controller@method)->name('cooperado.index')->middleware('auth');

Redirection

using this method unauthenticated user will redirect to login page.
in order to edit redirection page you can change '@redirectTo' method
in

app/Http/Middleware/Authenticate.php

file.


问:
Spring Boot 2.0 Hibernate 5 EhCache 3 with JCache
I'm trying to setup Hibernate with EhCache as the second level cache but the TTL is not working.

Here are my dependencies:

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

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-jcache</artifactId>
</dependency>

<dependency>
  <groupId>org.ehcache</groupId>
  <artifactId>ehcache</artifactId>
</dependency>

<dependency>
  <groupId>javax.cache</groupId>
  <artifactId>cache-api</artifactId>
</dependency>
</code>```

Here's my YAML configuration:

```<code>spring:
  jpa:
    show-sql: true
    properties:
      hibernate:
        dialect: Dialect
        cache:
          use_second_level_cache: true
          region.factory_class: org.hibernate.cache.jcache.JCacheRegionFactory
          use_query_cache: true
  cache:
    jcache:
      config: classpath:ehcache.xml
</code>```

Here's how my Entity class is configured:

```<code>@Entity
@javax.persistence.Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class PersonEntity {
  //
}
</code>```

And the JpaRepository for the entity:

```<code>public interface PersonRepository extends JpaRepository<PersonEntity, Integer> {
  @org.springframework.data.jpa.repository.QueryHints({
      @javax.persistence.QueryHint(name = "org.hibernate.cacheable", value = "true")
  })
  List<PersonEntity> findByName(String name);
}
</code>```

I've configured the cache to expire in 2 seconds, but calling findByName still uses the cache (there are no SQL Queries printed after the first one).

Here's the ehcache.xml file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.ehcache.org/v3">

  <cache-template name="simple">
    <expiry>
      <ttl>2</ttl>
    </expiry>
    <heap>100</heap>
  </cache-template>

  <cache alias="com.sample.PersonEntity" uses-template="simple"/>

</config>
</code>```

EDIT:
I've done some debugging. I've added a break point in org.ehcache.jsr107.ExpiryPolicyToEhcacheExpiry:

```<code>javax.cache.expiry.Duration duration = this.expiryPolicy.getExpiryForCreation();
</code>```

This duration is INFINITE for some reason. So maybe the configuration is not set properly? I know the xml is being read because when I invalidate it (by removing heap tag for example) I get an error.

答:
I think I found the cause of the issue - you didn't specify a location of the ehcache.xml file:

```<code>spring:
  jpa:
    properties:
      hibernate:
        javax.cache:
          provider: org.ehcache.jsr107.EhcacheCachingProvider
          uri: classpath:ehcache.xml
        cache:
          use_second_level_cache: true
          region.factory_class: jcache
          use_query_cache: true
</code>```

in this case Hibernate creates a cache with default configuration. A fragment from my demo project log:

17:15:19 WARN [main] org.hibernate.orm.cache: HHH90001006: Missing cache[user] was created on-the-fly. The created cache will use a provider-specific default configuration: make sure you defined one. You can disable this warning by setting 'hibernate.javax.cache.missing_cache_strategy' to 'create'.
```

Body:
I'm trying to setup Hibernate with EhCache as the second level cache but the TTL is not working.

Here are my dependencies:

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

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-jcache</artifactId>
</dependency>

<dependency>
  <groupId>org.ehcache</groupId>
  <artifactId>ehcache</artifactId>
</dependency>

<dependency>
  <groupId>javax.cache</groupId>
  <artifactId>cache-api</artifactId>
</dependency>

Here's my YAML configuration:

spring:
  jpa:
    show-sql: true
    properties:
      hibernate:
        dialect: Dialect
        cache:
          use_second_level_cache: true
          region.factory_class: org.hibernate.cache.jcache.JCacheRegionFactory
          use_query_cache: true
  cache:
    jcache:
      config: classpath:ehcache.xml

Here's how my Entity class is configured:

@Entity
@javax.persistence.Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class PersonEntity {
  //
}

And the JpaRepository for the entity:

public interface PersonRepository extends JpaRepository<PersonEntity, Integer> {
  @org.springframework.data.jpa.repository.QueryHints({
      @javax.persistence.QueryHint(name = "org.hibernate.cacheable", value = "true")
  })
  List<PersonEntity> findByName(String name);
}

I've configured the cache to expire in 2 seconds, but calling findByName still uses the cache (there are no SQL Queries printed after the first one).

Here's the ehcache.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.ehcache.org/v3">

  <cache-template name="simple">
    <expiry>
      <ttl>2</ttl>
    </expiry>
    <heap>100</heap>
  </cache-template>

  <cache alias="com.sample.PersonEntity" uses-template="simple"/>

</config>

EDIT:
I've done some debugging. I've added a break point in org.ehcache.jsr107.ExpiryPolicyToEhcacheExpiry:

javax.cache.expiry.Duration duration = this.expiryPolicy.getExpiryForCreation();

This duration is INFINITE for some reason. So maybe the configuration is not set properly? I know the xml is being read because when I invalidate it (by removing heap tag for example) I get an error.

Body:
I think I found the cause of the issue - you didn't specify a location of the ehcache.xml file:

spring:
  jpa:
    properties:
      hibernate:
        javax.cache:
          provider: org.ehcache.jsr107.EhcacheCachingProvider
          uri: classpath:ehcache.xml
        cache:
          use_second_level_cache: true
          region.factory_class: jcache
          use_query_cache: true

in this case Hibernate creates a cache with default configuration. A fragment from my demo project log:

17:15:19 WARN [main] org.hibernate.orm.cache: HHH90001006: Missing cache[user] was created on-the-fly. The created cache will use a provider-specific default configuration: make sure you defined one. You can disable this warning by setting 'hibernate.javax.cache.missing_cache_strategy' to 'create'.


问:
Multiply objects in an array witrh another object recursively in Java
Hello there I am learning Java and after doing some tasks to learn recursion I was giving my self some exercises to learn it a bit more but now I am struggeling with some..

So the main Problem is that I dont know how I can multiply every element in an Array recursively when the elements in that array are object (Maybe there is at the end no difference if objects are in there or not). So the exercise I gave myself was: check if 1 / 3 is in the given Array. If Yes then multiply everything in that array with 2 / 1.
This is Fraction:

 private int numerator;      // Zaehler
 private int denominator;    // Nenner

        public Fraction ( int num, int denom )
        {
            if ( denom != 0 )
            {
                if ( denom < 0 )
                {
                    numerator = -num;
                    denominator = -denom;
                }
                else
                {
                    numerator = num;
                    denominator = denom;
                }
                reduce();
            }
            else
            {
                // error: division by zero
                throw new IllegalArgumentException();
            }
        }

        public Fraction()
        {
            numerator = 0;
            denominator = 1;
        }

        public Fraction( int num )
        {
            numerator = num;
            denominator = 1;
        }
```

<p>So I got it done by doing it with an for loop: </p>

<pre class="lang-java prettyprint-override"><code>public static Fraction[] mulWithFor(Fraction[] arr)
        {
            for (int i = 0; i<arr.length; i++)
            {
                arr[i] = arr[i].multiply(new Fraction(2,1));
            }
            return arr;
        }
</code>```

But thats not my Main goal I want to do it recursively so that was my approach:

public static Fraction[] mulAus(Fraction[] arr, int i)
        {
            if (i>= 0 && i<arr.length)
            {
                rekurMul(arr,i);
                //return mulAus(rekurMul(arr,i-1));
            }
            return arr;
        }

        public static Fraction rekurMul(Fraction[] arr, int i)
        {
            if (i>= 0 && i<arr.length)
            {
                return arr[i].multiply(new Fraction(2,1));
                return arr[i].multiply(new Fraction(2, 1)); // Does Not Work!!!
            }
            throw new IndexOutOfBoundsException();
        }
```

<p>Maybe there is someone who can Help me! Thank you for your attention.</p>

<p>OK Thanks to @Chaï Sarfati and also to the others trying to help me out. I now know how to multiply recursive things in an Array! I used the Methods from @Chaï Sarfati but wrote an alternative method for his "oneThirdIsPresent" which is also a recursive method : So now my working code looks like this </p>

<pre class="lang-java prettyprint-override"><code> public static Fraction[] mulAus(Fraction[] arr)
        {
            if(contains(arr,arr.length-1,new Fraction(1,3)))
            {
                rekurMul(arr,0);
                return arr;
            }
            throw new IllegalArgumentException("1/3 does not exist in the Input-Array");
        }

        public static void rekurMul(Fraction[] arr, int i)
        {
            if(i == arr.length)
            {
                return ;
            }
            arr[i] = arr[i].multiply(new Fraction(2,1));
            rekurMul(arr,i+1);
        }
</code>```

The Method to check if 1 / 3 exists in the given Array.

public static boolean contains(Fraction[] arr, int i, Fraction x)
        {
            if (i>= 0 && i < arr.length)
            {
                if (arr[i].equals(x))
                { return true;}
                else
                { return contains(arr, i-1,x); }
            }
            return false;
        }
```

I hope other People can learn from the code.. Maybe there are better solutions but I am just starting Programming so I dont know them for now.
Bye

答:
Here's a quick example of just the recursive multiplication part:

```<code>public static void main(String[] args)
{
    Fraction[] fractions = new Fraction[] {new Fraction(1,2), new Fraction(2,3), new Fraction(3,1)};

    System.out.println("Fractions:");
    for(Fraction f: fractions)
    {
        System.out.println(f);
    }

    System.out.println("Multiplying array by 2...");
    Fraction.mulAus(fractions, new Fraction(2, 1));
    for(Fraction f: fractions)
    {
        System.out.println(f);
    }
}
</code>```

Modified Fraction Class (multiplication code at the bottom):

```<code>public class Fraction
{

        private int numerator;      // Zaehler
        private int denominator;    // Nenner

        public Fraction(int num, int denom)
        {
            if (denom != 0)
            {
                if (denom < 0)
                {
                    numerator = -num;
                    denominator = -denom;
                }
                else
                {
                    numerator = num;
                    denominator = denom;
                }
                reduce();
            }
            else
            {
                // error: division by zero
                //throw new IllegalArgumentException();
            }
        }

        private void reduce()
        {
            // ...
        }

        public Fraction()
        {
            numerator = 0;
            denominator = 1;
        }

        public Fraction(int num)
        {
            numerator = num;
            denominator = 1;
        }

        public String toString()
        {
            return numerator + " / " + denominator;
        }

        public void MultiplyBy(Fraction F)
        {
            if (F != null)
            {
                numerator = numerator * F.numerator;
                denominator = denominator * F.denominator;
                reduce();
            }
        }

        public static void mulAus(Fraction[] arr, Fraction F)
        {
            if(arr != null && F != null)
            {
                rekurMul(arr, 0, F);
            }
        }

        private static void rekurMul(Fraction[] arr, int i, Fraction F)
        {
            arr[i].MultiplyBy(F);
            if (i < (arr.length - 1))
            {
                rekurMul(arr, ++i, F);
            }
        }

}
</code>```

Output:

Body:
Hello there I am learning Java and after doing some tasks to learn recursion I was giving my self some exercises to learn it a bit more but now I am struggeling with some..

So the main Problem is that I dont know how I can multiply every element in an Array recursively when the elements in that array are object (Maybe there is at the end no difference if objects are in there or not). So the exercise I gave myself was: check if 1 / 3 is in the given Array. If Yes then multiply everything in that array with 2 / 1.
This is Fraction:

 private int numerator;      // Zaehler
 private int denominator;    // Nenner

        public Fraction ( int num, int denom )
        {
            if ( denom != 0 )
            {
                if ( denom < 0 )
                {
                    numerator = -num;
                    denominator = -denom;
                }
                else
                {
                    numerator = num;
                    denominator = denom;
                }
                reduce();
            }
            else
            {
                // error: division by zero
                throw new IllegalArgumentException();
            }
        }

        public Fraction()
        {
            numerator = 0;
            denominator = 1;
        }

        public Fraction( int num )
        {
            numerator = num;
            denominator = 1;
        }

So I got it done by doing it with an for loop:

public static Fraction[] mulWithFor(Fraction[] arr)
        {
            for (int i = 0; i<arr.length; i++)
            {
                arr[i] = arr[i].multiply(new Fraction(2,1));
            }
            return arr;
        }

But thats not my Main goal I want to do it recursively so that was my approach:

public static Fraction[] mulAus(Fraction[] arr, int i)
        {
            if (i>= 0 && i<arr.length)
            {
                rekurMul(arr,i);
                //return mulAus(rekurMul(arr,i-1));
            }
            return arr;
        }

        public static Fraction rekurMul(Fraction[] arr, int i)
        {
            if (i>= 0 && i<arr.length)
            {
                return arr[i].multiply(new Fraction(2,1));
                return arr[i].multiply(new Fraction(2, 1)); // Does Not Work!!!
            }
            throw new IndexOutOfBoundsException();
        }

Maybe there is someone who can Help me! Thank you for your attention.

OK Thanks to @Chaï Sarfati and also to the others trying to help me out. I now know how to multiply recursive things in an Array! I used the Methods from @Chaï Sarfati but wrote an alternative method for his "oneThirdIsPresent" which is also a recursive method : So now my working code looks like this

 public static Fraction[] mulAus(Fraction[] arr)
        {
            if(contains(arr,arr.length-1,new Fraction(1,3)))
            {
                rekurMul(arr,0);
                return arr;
            }
            throw new IllegalArgumentException("1/3 does not exist in the Input-Array");
        }

        public static void rekurMul(Fraction[] arr, int i)
        {
            if(i == arr.length)
            {
                return ;
            }
            arr[i] = arr[i].multiply(new Fraction(2,1));
            rekurMul(arr,i+1);
        }

The Method to check if 1 / 3 exists in the given Array.

public static boolean contains(Fraction[] arr, int i, Fraction x)
        {
            if (i>= 0 && i < arr.length)
            {
                if (arr[i].equals(x))
                { return true;}
                else
                { return contains(arr, i-1,x); }
            }
            return false;
        }

I hope other People can learn from the code.. Maybe there are better solutions but I am just starting Programming so I dont know them for now.
Bye

Body:
Here's a quick example of just the recursive multiplication part:

public static void main(String[] args)
{
    Fraction[] fractions = new Fraction[] {new Fraction(1,2), new Fraction(2,3), new Fraction(3,1)};

    System.out.println("Fractions:");
    for(Fraction f: fractions)
    {
        System.out.println(f);
    }

    System.out.println("Multiplying array by 2...");
    Fraction.mulAus(fractions, new Fraction(2, 1));
    for(Fraction f: fractions)
    {
        System.out.println(f);
    }
}

Modified Fraction Class (multiplication code at the bottom):

public class Fraction
{

        private int numerator;      // Zaehler
        private int denominator;    // Nenner

        public Fraction(int num, int denom)
        {
            if (denom != 0)
            {
                if (denom < 0)
                {
                    numerator = -num;
                    denominator = -denom;
                }
                else
                {
                    numerator = num;
                    denominator = denom;
                }
                reduce();
            }
            else
            {
                // error: division by zero
                //throw new IllegalArgumentException();
            }
        }

        private void reduce()
        {
            // ...
        }

        public Fraction()
        {
            numerator = 0;
            denominator = 1;
        }

        public Fraction(int num)
        {
            numerator = num;
            denominator = 1;
        }

        public String toString()
        {
            return numerator + " / " + denominator;
        }

        public void MultiplyBy(Fraction F)
        {
            if (F != null)
            {
                numerator = numerator * F.numerator;
                denominator = denominator * F.denominator;
                reduce();
            }
        }

        public static void mulAus(Fraction[] arr, Fraction F)
        {
            if(arr != null && F != null)
            {
                rekurMul(arr, 0, F);
            }
        }

        private static void rekurMul(Fraction[] arr, int i, Fraction F)
        {
            arr[i].MultiplyBy(F);
            if (i < (arr.length - 1))
            {
                rekurMul(arr, ++i, F);
            }
        }

}

Output:


问:
Is an empty href valid?
One of our web developers uses the following html as a placeholder for styling a drop down list.

```<code><a href="" class="arrow"></a>
</code>```

Is this considered anchor tag valid?

Since there is no href value, it shows up as broken on some of our link checker reports.

答: Try to do href="#" class="arrow"> instead. (Note the sharp # character).

Title: Is an empty href valid?

Body:
One of our web developers uses the following html as a placeholder for styling a drop down list.

Is this considered anchor tag valid?

Since there is no href value, it shows up as broken on some of our link checker reports.

Body: Try to do <a href="#" class="arrow"> instead. (Note the sharp # character).


问:
Spring Boot 2 Migration - org.h2.jdbc.JdbcSQLException: Sequence not found
I'm in the process of migrating an application from Spring Boot 1.5.4 to Spring Boot 2.0.4. I think I was successful in migrating all the dependencies needed for Spring Boot, however now when I start the application, which is supposed to insert a new record into an h2 database I get the following error:

```<code>2018-08-21 16:13:18,958 WARN  [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @129 - SQL Error: 90036, SQLState: 90036
2018-08-21 16:13:18,958 ERROR [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @131 - Sequence "PLAN_PLAN_ID_SEQ" not found; SQL statement:
call next value for plan_plan_id_seq [90036-197]
</code>```

After enabling "TRACE" logs for Hibenate this is the log I get:

```2018-08-21 16:13:18,941 DEBUG [restartedMain] --- o.h.SQL.logStatement() : @92 - call next value for plan_plan_id_seq
Hibernate: call next value for plan_plan_id_seq
2018-08-21 16:13:18,942 DEBUG [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @124 - could not prepare statement [call next value for plan_plan_id_seq]
org.h2.jdbc.JdbcSQLException: Sequence "PLAN_PLAN_ID_SEQ" not found; SQL statement:
call next value for plan_plan_id_seq [90036-197]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:357) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.message.DbException.get(DbException.java:179) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.message.DbException.get(DbException.java:155) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readSequence(Parser.java:5970) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readTerm(Parser.java:3131) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readFactor(Parser.java:2587) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readSum(Parser.java:2574) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readConcat(Parser.java:2544) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readCondition(Parser.java:2370) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readAnd(Parser.java:2342) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readExpression(Parser.java:2334) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.parseCall(Parser.java:4854) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.parsePrepared(Parser.java:382) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.parse(Parser.java:335) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.parse(Parser.java:307) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.prepareCommand(Parser.java:278) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.engine.Session.prepareLocal(Session.java:611) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.engine.Session.prepareCommand(Session.java:549) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:76) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:304) ~[h2-1.4.197.jar:1.4.197]
    at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:318) ~[HikariCP-2.7.9.jar:?]
    at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java) ~[HikariCP-2.7.9.jar:?]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$1.doPrepare(StatementPreparerImpl.java:86) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:171) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:72) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.id.enhanced.SequenceStructure$1.getNextValue(SequenceStructure.java:93) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.id.enhanced.NoopOptimizer.generate(NoopOptimizer.java:40) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.id.enhanced.SequenceStyleGenerator.generate(SequenceStyleGenerator.java:452) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:105) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(JpaPersistEventListener.java:67) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:783) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:768) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:305) ~[spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at com.sun.proxy.$Proxy204.persist(Unknown Source) ~[?:?]
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:490) ~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
    at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:377) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:629) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:593) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:578) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) ~[spring-tx-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:135) ~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at com.sun.proxy.$Proxy212.save(Unknown Source) ~[?:?]
    at com.myapp.server.service.plans.PlanService.setFirstDefaultPlanIfNeeded(PlanService.java:244) ~[classes/:?]
    at com.myapp.server.service.plans.PlanService.initDefaultPlan(PlanService.java:64) ~[classes/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:309) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1691) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1124) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1124) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) [spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) [spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at com.morphisec.server.ServerApplication.main(ServerApplication.java:79) [classes/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.4.RELEASE.jar:2.0.4.RELEASE]
2018-08-21 16:13:18,958 WARN  [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @129 - SQL Error: 90036, SQLState: 90036
2018-08-21 16:13:18,958 ERROR [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @131 - Sequence "PLAN_PLAN_ID_SEQ" not found; SQL statement:
call next value for plan_plan_id_seq [90036-197]
```

<p>This is my AbstractPlan class:</p>

```@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name= DBConstants.PLAN_TABLE_ABSTRACT_TYPE, discriminatorType = DiscriminatorType.STRING)
@Table(name =  DBConstants.PLAN_TBL)
@JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "jsonUUID")
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include= JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
        @JsonSubTypes.Type(name=DBConstants.PLAN_DESCRIMINATOR_VALUE, value=Plan.class),
        @JsonSubTypes.Type(name=DBConstants.TROUBLESHOOT_DESCRIMINATOR_VALUE, value=Troubleshoot.class)})
@Getter
@Setter
public abstract class AbstractPlan {

    @Id
    @Column(name = DBConstants.PLAN_ID)
    @SequenceGenerator(sequenceName = "plan_plan_id_seq", name = "plan_id_pk_seq", allocationSize = 1)
    @GeneratedValue(strategy=GenerationType.AUTO, generator = "plan_id_pk_seq")
    protected Long id;

}
```

I have no idea as to why this happening, since it worked fine before the migration process. Any help is much appreciated, thanks!

答: So, we had a similar issues and it seems like global setting up database-platform was causing it. So, we had to remove the following jpa.database-platform: org.hibernate.dialect.PostgreSQL9Dialect as it was somehow over-writing spring.datasource.platform: h2.

Body:
I'm in the process of migrating an application from Spring Boot 1.5.4 to Spring Boot 2.0.4. I think I was successful in migrating all the dependencies needed for Spring Boot, however now when I start the application, which is supposed to insert a new record into an h2 database I get the following error:

2018-08-21 16:13:18,958 WARN  [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @129 - SQL Error: 90036, SQLState: 90036
2018-08-21 16:13:18,958 ERROR [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @131 - Sequence "PLAN_PLAN_ID_SEQ" not found; SQL statement:
call next value for plan_plan_id_seq [90036-197]

After enabling "TRACE" logs for Hibenate this is the log I get:

2018-08-21 16:13:18,941 DEBUG [restartedMain] --- o.h.SQL.logStatement() : @92 - call next value for plan_plan_id_seq
Hibernate: call next value for plan_plan_id_seq
2018-08-21 16:13:18,942 DEBUG [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @124 - could not prepare statement [call next value for plan_plan_id_seq]
org.h2.jdbc.JdbcSQLException: Sequence "PLAN_PLAN_ID_SEQ" not found; SQL statement:
call next value for plan_plan_id_seq [90036-197]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:357) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.message.DbException.get(DbException.java:179) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.message.DbException.get(DbException.java:155) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readSequence(Parser.java:5970) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readTerm(Parser.java:3131) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readFactor(Parser.java:2587) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readSum(Parser.java:2574) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readConcat(Parser.java:2544) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readCondition(Parser.java:2370) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readAnd(Parser.java:2342) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.readExpression(Parser.java:2334) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.parseCall(Parser.java:4854) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.parsePrepared(Parser.java:382) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.parse(Parser.java:335) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.parse(Parser.java:307) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.command.Parser.prepareCommand(Parser.java:278) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.engine.Session.prepareLocal(Session.java:611) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.engine.Session.prepareCommand(Session.java:549) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1247) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:76) ~[h2-1.4.197.jar:1.4.197]
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:304) ~[h2-1.4.197.jar:1.4.197]
    at com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:318) ~[HikariCP-2.7.9.jar:?]
    at com.zaxxer.hikari.pool.HikariProxyConnection.prepareStatement(HikariProxyConnection.java) ~[HikariCP-2.7.9.jar:?]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$1.doPrepare(StatementPreparerImpl.java:86) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:171) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:72) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.id.enhanced.SequenceStructure$1.getNextValue(SequenceStructure.java:93) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.id.enhanced.NoopOptimizer.generate(NoopOptimizer.java:40) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.id.enhanced.SequenceStyleGenerator.generate(SequenceStyleGenerator.java:452) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:105) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(JpaPersistEventListener.java:67) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:783) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:768) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:305) ~[spring-orm-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at com.sun.proxy.$Proxy204.persist(Unknown Source) ~[?:?]
    at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:490) ~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
    at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:377) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:629) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:593) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:578) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) ~[spring-tx-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) ~[spring-tx-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:135) ~[spring-data-jpa-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.0.9.RELEASE.jar:2.0.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at com.sun.proxy.$Proxy212.save(Unknown Source) ~[?:?]
    at com.myapp.server.service.plans.PlanService.setFirstDefaultPlanIfNeeded(PlanService.java:244) ~[classes/:?]
    at com.myapp.server.service.plans.PlanService.initDefaultPlan(PlanService.java:64) ~[classes/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:366) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:309) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1691) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1124) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1341) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:572) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:818) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:724) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:197) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1267) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1124) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) [spring-beans-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) [spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) [spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:398) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at com.morphisec.server.ServerApplication.main(ServerApplication.java:79) [classes/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.4.RELEASE.jar:2.0.4.RELEASE]
2018-08-21 16:13:18,958 WARN  [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @129 - SQL Error: 90036, SQLState: 90036
2018-08-21 16:13:18,958 ERROR [restartedMain] --- o.h.e.j.s.SqlExceptionHelper.logExceptions() : @131 - Sequence "PLAN_PLAN_ID_SEQ" not found; SQL statement:
call next value for plan_plan_id_seq [90036-197]

This is my AbstractPlan class:

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name= DBConstants.PLAN_TABLE_ABSTRACT_TYPE, discriminatorType = DiscriminatorType.STRING)
@Table(name =  DBConstants.PLAN_TBL)
@JsonIdentityInfo(generator = ObjectIdGenerators.UUIDGenerator.class, property = "jsonUUID")
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include= JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
        @JsonSubTypes.Type(name=DBConstants.PLAN_DESCRIMINATOR_VALUE, value=Plan.class),
        @JsonSubTypes.Type(name=DBConstants.TROUBLESHOOT_DESCRIMINATOR_VALUE, value=Troubleshoot.class)})
@Getter
@Setter
public abstract class AbstractPlan {

    @Id
    @Column(name = DBConstants.PLAN_ID)
    @SequenceGenerator(sequenceName = "plan_plan_id_seq", name = "plan_id_pk_seq", allocationSize = 1)
    @GeneratedValue(strategy=GenerationType.AUTO, generator = "plan_id_pk_seq")
    protected Long id;

}

I have no idea as to why this happening, since it worked fine before the migration process. Any help is much appreciated, thanks!


问:
Live update of Kubernetes container environment variable derived from configMapRef
For one of my containers inside a pod I set some of the environment variables using envFrom:

```<code>envFrom:
  - configMapRef:
      name: my-config-map
</code>```

Experimenting, it seems that updating the ConfigMap does not change the value of the corresponding environment value in the container.

Is there some way to force the update of the environment variable when setting them using configMapRef? If not, where is this limitation explicitly documented?

答:
The environment variables are set when the container is starting so there is no possible way to update those environment variables. You will need to restart Pod so it that reads again the ConfigMap values and sets the environment for the new created container.

You can do this automatically with some tools out there, like reloader, which will

watch changes in ConfigMap and Secrets and then restart pods for Deployment

Body:
For one of my containers inside a pod I set some of the environment variables using envFrom:

envFrom:
  - configMapRef:
      name: my-config-map

Experimenting, it seems that updating the ConfigMap does not change the value of the corresponding environment value in the container.

Is there some way to force the update of the environment variable when setting them using configMapRef? If not, where is this limitation explicitly documented?


问:
Error: "There was an error running the selected code generator: Package restore failed"
I am trying to add controller to my solution in ASP.NET Core project:

When I try to do so I get this error:

I get the same message for adding minimal dependencies and full dependencies for controller.

答: All I had to do was open the properties of my web project and change the TargetFramework from 2.1 to 2.2. Or to match whatever version of the framework your business and object layer are using.</p>


问:
How to create and use an "out" parameter with a SQL Server database
I am working on a C# desktop application. I want to use a stored procedure (insert query) to add a new record to a data table. I need to return the primary key which is an identity insert (bigint) to avoid another round trip to the database. I have searched the MS Help(less) files for a couple of hours and found nothing on how to set the out parameter of the stored procedure or how to obtain the return value.

答:
I get the impression you're trying to go from three round trips, like this:

```<code>INSERT => SELECT to get key => OTHER INSERT using previous key
</code>```

to two

```<code>INSERT returns the key => OTHER INSERT using previous key
</code>```

We can do better.

One way to resolve this is sending more than one command in the sql string from C#. So you end up with something like this, which achieves the goal of avoiding extra round-trips to the database:

```<code>string sql = @"
   DECLARE @ID int;
   EXEC InsertProcedure;
   SELECT @ID = scope_identity();
   INSERT INTO OtherTable VALUES (@ID);";

using (var cn = new SqlConnection("connection string"))
using (var cmd = new SqlCommand(sql, cn))
{
    cn.Open();
    cmd.ExecuteNonQuery();
}
</code>```

Alternatively, maybe you just want the key for use in your application, so you can continue to work with the record and have fast lookups via that new clustered index value. In that case, you can still do it this way:

```<code>string sql = @"
   DECLARE @ID int;
   EXEC InsertProcedure;
   SELECT scope_identity();";

using (var cn = new SqlConnection("connection string"))
using (var cmd = new SqlCommand(sql, cn))
{
    cn.Open();
    return (int)cmd.ExecuteScalar();
}
</code>```

Just be careful whether the stored procedure has any unresolved select queries of it's own, in which case you'll need to use ExecuteReader(), along with it's NextResult() method to advance between SELECT query results.

Of course, there's likely more to it than that for your real code, where you need parameters for the new data to insert, but this provides the general concept.

Body:
I get the impression you're trying to go from three round trips, like this:

INSERT => SELECT to get key => OTHER INSERT using previous key

to two

INSERT returns the key => OTHER INSERT using previous key

We can do better.

One way to resolve this is sending more than one command in the sql string from C#. So you end up with something like this, which achieves the goal of avoiding extra round-trips to the database:

string sql = @"
   DECLARE @ID int;
   EXEC InsertProcedure;
   SELECT @ID = scope_identity();
   INSERT INTO OtherTable VALUES (@ID);";

using (var cn = new SqlConnection("connection string"))
using (var cmd = new SqlCommand(sql, cn))
{
    cn.Open();
    cmd.ExecuteNonQuery();
}

Alternatively, maybe you just want the key for use in your application, so you can continue to work with the record and have fast lookups via that new clustered index value. In that case, you can still do it this way:

string sql = @"
   DECLARE @ID int;
   EXEC InsertProcedure;
   SELECT scope_identity();";

using (var cn = new SqlConnection("connection string"))
using (var cmd = new SqlCommand(sql, cn))
{
    cn.Open();
    return (int)cmd.ExecuteScalar();
}

Just be careful whether the stored procedure has any unresolved select queries of it's own, in which case you'll need to use ExecuteReader(), along with it's NextResult() method to advance between SELECT query results.

Of course, there's likely more to it than that for your real code, where you need parameters for the new data to insert, but this provides the general concept.


问:
Make custom checkbox switch Label element a11y tab / keyboard accessible
So I'm trying to make custom slider that's cross browser (IE11, Chrome, Firefox, Edge) that's also a11y accessible and I'm having trouble getting the label element to respond to space bar for selection like a natural checkbox. I can do it easily with code of course but was curious if there's maybe something I'm missing with just the html/css I could do to accomplish the same thing.

As example see below, tabindex of course provides the visual and tabbing, but I can't seem to get the label to toggle it like a click would on label element. Should I just go the easy route and let some code handle it or does someone want to teach me something? Cheers!

// not yet, and yes I know I haven't added the aria attributes etc, it's just a quick PoC :)```
<pre class="snippet-code-css lang-css prettyprint-override"><code>main {
  display: block;
  margin: 0 auto;
  padding: 2rem;
  width: auto;
}

.slide-toggle {
  margin: 0 3rem;
  display: inline-block;
}
.slide-toggle:last-of-type {
  margin-left: 0;
}
.slide-toggle input {
  display: none;
}
.slide-toggle input:checked ~ label {
  color: #fff;
  background-color: skyblue;
}
.slide-toggle input:checked ~ label:after {
  transform: translateX(100%);
}
.slide-toggle label {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: .25rem 0;
  cursor: pointer;
  user-select: none;
  border: #bbb 1px solid;
  border-radius: 3px;
}
.slide-toggle label:after {
  display: block;
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 45%;
  margin: .25rem;
  border: #bbb 1px solid;
  border-radius: 3px;
  background-color: #ddd;
  transition: transform 0.25s cubic-bezier(0.6, 0.82, 0, 0.76);
}
.slide-toggle label:focus {
  box-shadow: 0 0 0 8px red;
}
.slide-toggle label:hover {
  border-color: #777;
}
.slide-toggle label div {
  flex-grow: 1;
  flex-basis: 50%;
  flex-wrap: nowrap;
  text-align: center;
  min-width: 1rem;
  margin: .25rem 1rem;
}</code>```

<link href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" rel="stylesheet"/>

Please click a slide toggle for example;

    <input id="guidLater"
           type="checkbox"/>

YES

NO

  No Translation Option:

    <input id="guidLater4"
           type="checkbox"/>

```

答:
Without getting too far into the specifics, as there are many, I'll just attack this from a pure solution perspective and provide some insight.

With HTML5 elements, the idea is that they have functionality assigned to them by default. For example, a checkbox inherits the behaviors that a checkbox should have because it's a default element. You also shouldn't be re-purposing elements for other uses if native ones are available as this breaks the first two rules of ARIA.

If you can use a native HTML element [HTML51] or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so.

And

Do not change native semantics, unless you really have to.

The input types of Range (a slider) and Checkbox have two vastly different sets of keyboard behaviors, so i'm not surprised that this isn't working correctly.

Body:
So I'm trying to make custom slider that's cross browser (IE11, Chrome, Firefox, Edge) that's also a11y accessible and I'm having trouble getting the label element to respond to space bar for selection like a natural checkbox. I can do it easily with code of course but was curious if there's maybe something I'm missing with just the html/css I could do to accomplish the same thing.

As example see below, tabindex of course provides the visual and tabbing, but I can't seem to get the label to toggle it like a click would on label element. Should I just go the easy route and let some code handle it or does someone want to teach me something? Cheers!

// not yet, and yes I know I haven't added the aria attributes etc, it's just a quick PoC :)

main {
  display: block;
  margin: 0 auto;
  padding: 2rem;
  width: auto;
}

.slide-toggle {
  margin: 0 3rem;
  display: inline-block;
}
.slide-toggle:last-of-type {
  margin-left: 0;
}
.slide-toggle input {
  display: none;
}
.slide-toggle input:checked ~ label {
  color: #fff;
  background-color: skyblue;
}
.slide-toggle input:checked ~ label:after {
  transform: translateX(100%);
}
.slide-toggle label {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: .25rem 0;
  cursor: pointer;
  user-select: none;
  border: #bbb 1px solid;
  border-radius: 3px;
}
.slide-toggle label:after {
  display: block;
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 45%;
  margin: .25rem;
  border: #bbb 1px solid;
  border-radius: 3px;
  background-color: #ddd;
  transition: transform 0.25s cubic-bezier(0.6, 0.82, 0, 0.76);
}
.slide-toggle label:focus {
  box-shadow: 0 0 0 8px red;
}
.slide-toggle label:hover {
  border-color: #777;
}
.slide-toggle label div {
  flex-grow: 1;
  flex-basis: 50%;
  flex-wrap: nowrap;
  text-align: center;
  min-width: 1rem;
  margin: .25rem 1rem;
}

<link href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" rel="stylesheet"/>

Please click a slide toggle for example;

    <input id="guidLater"
           type="checkbox"/>

YES

NO

  No Translation Option:

    <input id="guidLater4"
           type="checkbox"/>


问:
could not find implicit value for parameter encoder: io.circe.Encoder[com.sweetsoft.SapHealth]
I have the following code, that does not compile:

```<code>import java.time.Instant

import io.circe.{Decoder, Encoder}
import io.circe.generic.auto._
import io.circe.syntax._

trait SapHealth {}

case class SapHealthRejected(reason: String) extends SapHealth

case class SapHealthAccepted(sapId: String, requestedAt: Long) extends SapHealth

object SapHealth {

  private val build: SapHealth = SapHealthAccepted(SapmockActor.system.name, Instant.now().getEpochSecond)

  val create: String = build.asJson.noSpaces

  implicit val encodeFieldType: Encoder[SapHealthAccepted] =
    Encoder.forProduct2("sap-id", "requested_at")(SapHealthAccepted.unapply(_).get)

  implicit val decodeFieldType: Decoder[SapHealthAccepted] =
    Decoder.forProduct2("sap-id", "requested_at")(SapHealthAccepted.apply)

}
</code>```

The compiler complains:

```<code>could not find implicit value for parameter encoder: io.circe.Encoder[com.sweetsoft.SapHealth]
[error]   val create: String = build.asJson.noSpaces
</code>```

What am I missing?

答: Trait SapHealth should be sealed.

Body:
I have the following code, that does not compile:

import java.time.Instant

import io.circe.{Decoder, Encoder}
import io.circe.generic.auto._
import io.circe.syntax._

trait SapHealth {}

case class SapHealthRejected(reason: String) extends SapHealth

case class SapHealthAccepted(sapId: String, requestedAt: Long) extends SapHealth

object SapHealth {

  private val build: SapHealth = SapHealthAccepted(SapmockActor.system.name, Instant.now().getEpochSecond)

  val create: String = build.asJson.noSpaces

  implicit val encodeFieldType: Encoder[SapHealthAccepted] =
    Encoder.forProduct2("sap-id", "requested_at")(SapHealthAccepted.unapply(_).get)

  implicit val decodeFieldType: Decoder[SapHealthAccepted] =
    Decoder.forProduct2("sap-id", "requested_at")(SapHealthAccepted.apply)

}

The compiler complains:

could not find implicit value for parameter encoder: io.circe.Encoder[com.sweetsoft.SapHealth]
[error]   val create: String = build.asJson.noSpaces

What am I missing?

Body: Trait SapHealth should be sealed.