答:
You normally install Rails by only using gem, you only install "by hand" if it is not hosted  anywhere.

Do the following steps (I suppose that ruby is installed and the gem command is working):

gem install rails -v 2.3.5

This should include all needed gems as well, and will install the rails command in your shell. However, to use it in Windows is a little bit difficult, because the installation of sqlite3 is not so easy.

Title: How do I install Rails?

Body:
I am completely new to Ruby and need to use Ruby on Rails 2.3.5 on Windows. I have downloaded the zip from GitHub here: https://github.com/rails/rails/tree/v2.3.5

There was no gem file so I tried rake in the extracted directory. It took ages and seemed to have a lot of errors, but it did eventually complete.

There was no gem file created (is this even what rake is supposed to do?). And rails is not installed (typing rails at the command prompt doesnt work).

Any ideas what I am doing wrong?

EDIT: I cannot use gem install rails -v "2.3.5" as I am behind a firewall. I think I need to install it from local files.


来源: stackexchange

问:
Troubles on constructing HLS using libp2p-http
I intend to implement a classic HLS example with libp2p, which is as follows
https://hackernoon.com/building-a-media-streaming-server-using-go-and-hls-protocol-j85h3wem
But I encountered the following errors：

404 page not found

My code constructing linstening:

```<code>m1, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/1000")
    m2, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/1001")
    srvHost := NewHost(m1)
    clientHost := NewHost(m2)
    defer srvHost.Close()
    defer clientHost.Close()

    srvHost.Peerstore().AddAddrs(clientHost.ID(), clientHost.Addrs(), peerstore.PermanentAddrTTL)
    fmt.Println("id is", clientHost.ID())
    fmt.Println("addr is", srvHost.Addrs())
    clientHost.Peerstore().AddAddrs(srvHost.ID(), srvHost.Addrs(), peerstore.PermanentAddrTTL)

    listener, err := gostream.Listen(srvHost, "/testiti-test")
    if err != nil {
        panic(err)
    }
    defer listener.Close()
</code>```

My code constructing client:

```<code>tr := &http.Transport{}
    tr.RegisterProtocol("libp2p", p2phttp.NewTransport(clientHost, p2phttp.ProtocolOption("/testiti-test")))
client := &http.Client{Transport: tr}

res, err := client.Get(fmt.Sprintf("libp2p://%s/simple", port))
if err != nil {
    panic(err)
}
data, err := ioutil.ReadAll(res.Body)
defer res.Body.Close()
if err != nil {
    log.Fatal(err)
}
fmt.Println(string(data))
</code>```

My code constructing sever:

```<code>go func() {
        http.HandleFunc("/simple", addHeaders(http.FileServer(http.Dir(songsDir))))
        //http.HandleFunc("/simple", addHeaders2())
        fmt.Printf("Starting server on %v\n", port)
        log.Printf("Serving %s on HTTP port: %v\n", songsDir, port)

        server := &http.Server{}
        server.Serve(listener)
    }()
func addHeaders(h http.Handler) http.HandlerFunc {
    return func(w http.ResponseWriter, r *http.Request) {
        w.Header().Set("Access-Control-Allow-Origin", "*")
        h.ServeHTTP(w, r)
    }
}
</code>```

New host:

```<code>func NewHost(listen multiaddr.Multiaddr) host.Host {
    h, err := libp2p.New(
        libp2p.ListenAddrs(listen),
    )
    if err != nil {
        panic(err)
    }
    return h
}
</code>```

答:
The problem is casued by routing.For a http.FileServer,"\simple" means a dir but   not a url.So just fix like this:</p>
```<code>url := fmt.Sprintf("libp2p://%s/origin.m3u8", port)
res, err := client.Get(url)
if err != nil {
    panic(err)
}
data, err := ioutil.ReadAll(res.Body)
defer res.Body.Close()
if err != nil {
    log.Fatal(err)
}
fmt.Println(string(data))
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I intend to implement a classic HLS example with libp2p, which is as follows
https://hackernoon.com/building-a-media-streaming-server-using-go-and-hls-protocol-j85h3wem
But I encountered the following errors：

404 page not found

My code constructing linstening:

m1, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/1000")
    m2, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/1001")
    srvHost := NewHost(m1)
    clientHost := NewHost(m2)
    defer srvHost.Close()
    defer clientHost.Close()

    srvHost.Peerstore().AddAddrs(clientHost.ID(), clientHost.Addrs(), peerstore.PermanentAddrTTL)
    fmt.Println("id is", clientHost.ID())
    fmt.Println("addr is", srvHost.Addrs())
    clientHost.Peerstore().AddAddrs(srvHost.ID(), srvHost.Addrs(), peerstore.PermanentAddrTTL)

    listener, err := gostream.Listen(srvHost, "/testiti-test")
    if err != nil {
        panic(err)
    }
    defer listener.Close()

My code constructing client:

tr := &http.Transport{}
    tr.RegisterProtocol("libp2p", p2phttp.NewTransport(clientHost, p2phttp.ProtocolOption("/testiti-test")))
client := &http.Client{Transport: tr}

res, err := client.Get(fmt.Sprintf("libp2p://%s/simple", port))
if err != nil {
    panic(err)
}
data, err := ioutil.ReadAll(res.Body)
defer res.Body.Close()
if err != nil {
    log.Fatal(err)
}
fmt.Println(string(data))

My code constructing sever:

go func() {
        http.HandleFunc("/simple", addHeaders(http.FileServer(http.Dir(songsDir))))
        //http.HandleFunc("/simple", addHeaders2())
        fmt.Printf("Starting server on %v\n", port)
        log.Printf("Serving %s on HTTP port: %v\n", songsDir, port)

        server := &http.Server{}
        server.Serve(listener)
    }()
func addHeaders(h http.Handler) http.HandlerFunc {
    return func(w http.ResponseWriter, r *http.Request) {
        w.Header().Set("Access-Control-Allow-Origin", "*")
        h.ServeHTTP(w, r)
    }
}

New host:

func NewHost(listen multiaddr.Multiaddr) host.Host {
    h, err := libp2p.New(
        libp2p.ListenAddrs(listen),
    )
    if err != nil {
        panic(err)
    }
    return h
}

Body:
The problem is casued by routing.For a http.FileServer,"\simple" means a dir but   not a url.So just fix like this:

url := fmt.Sprintf("libp2p://%s/origin.m3u8", port)
res, err := client.Get(url)
if err != nil {
    panic(err)
}
data, err := ioutil.ReadAll(res.Body)
defer res.Body.Close()
if err != nil {
    log.Fatal(err)
}
fmt.Println(string(data))


问:
How to fix position image on another image
I have the following code (also pasted below), where I want to make a layout of two columns. In the first one I am putting two images, and in the second displaying some text.

In the first column, I want to have the first image with width:70% and the second one with position:absolute on it. The final result should be like this

As you see the second image partially located in first one in every screens above to 768px.

I can partially locate second image on first one, but that is not dynamic, if you change screen dimensions you can see how that collapse.

But no matter how hard I try, I can not achieve this result.

.checkoutWrapper {
  display: grid;
  grid-template-columns: 50% 50%;
}

.coverIMGLast {
  width: 70%;
  height: 100vh;
}

/* this .phone class should be dynamically  located partially on first image */
.phone {
  position: absolute;
  height: 90%;
  top: 5%;
  bottom: 5%;
  margin-left: 18%;
}

.CheckoutProcess {
  padding: 5.8rem 6.4rem;
}

.someContent {
  border: 1px solid red;
}

/* removing for demo purposes
@media screen and (max-width: 768px) {
  .checkoutWrapper {
    display: grid;
    grid-template-columns: 100%;
  }
  img {
    display: none;
  }
  .CheckoutProcess {
    padding: 0;
  }
}
*/```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="checkoutWrapper">
  <img src="https://via.placeholder.com/300" class="coverIMGLast" />
  <img src="https://via.placeholder.com/300/ff0000" class="phone" />

  <div class="CheckoutProcess">
    <Content />
  </div>
</div></code>```

答:
```<code>* {
  margin: 0;
}

.checkoutWrapper {
  display: grid;
  grid-template-columns: 35% 25% 40%; /* create three columns to fit both images  */
}

.coverIMGLast {
  width: calc(100% - 195px); **/* give that illution of real overlapping */**
  height: 100vh; /* please don't delete this line */
  grid-column: 1 / 3; /* overlapping */
  grid-row: 1;
  object-fit: cover;
}
/* this .phone class should be dynamically  located partially on first image */
.phone {
  height: 90vh;
  width: 380px;
  grid-row: 1; /* setting the images on one track / row */
  grid-column: 1/3; /* overlaping */
  justify-self: end;
  transform: translateY(5vh);
}

.CheckoutProcess {
  padding: 5.8rem 0.5rem 6.4rem; /* Add normal padding to give that effect */
}

.someContent {
  border: 1px solid red;
}

@media screen and (max-width: 768px) {
  .checkoutWrapper {
    display: grid;
    grid-template-columns: 100%;
  }

  img {
    display: none;
  }

  .CheckoutProcess {
    padding: 0;
  }
}
</code>```
```<code><div class="checkoutWrapper">
  <img src="https://via.placeholder.com/300" class="coverIMGLast" />
  <img src="https://via.placeholder.com/300/ff0000" class="phone" />
  <div class="CheckoutProcess">
    <div class="someContent">
      <h1>Some heading</h1>
      <p>
        Some text to go with the paragraph
      </p>
    </div>
  </div>
</div>
</code>```

https://react-2djy5g-tsheob.stackblitz.io/

As you can see from the above code and link of your edited code.

You just had to make an illusion of the overlapping by using grid-column and playing with the template columns to create a book-like feeling.

with :

grid-template-columns: 35% 25% 40%; /* create three columns to fit both images  */

grid-row: 1;          /* setting the images on one track / row */

grid-column: 1/3;    /* overlaping */

justify-self: end;  /* placing image on the right side of the grid */

Body:
I have the following code (also pasted below), where I want to make a layout of two columns. In the first one I am putting two images, and in the second displaying some text.

In the first column, I want to have the first image with width:70% and the second one with position:absolute on it. The final result should be like this

As you see the second image partially located in first one in every screens above to 768px.

I can partially locate second image on first one, but that is not dynamic, if you change screen dimensions you can see how that collapse.

But no matter how hard I try, I can not achieve this result.

.checkoutWrapper {
  display: grid;
  grid-template-columns: 50% 50%;
}

.coverIMGLast {
  width: 70%;
  height: 100vh;
}

/* this .phone class should be dynamically  located partially on first image */
.phone {
  position: absolute;
  height: 90%;
  top: 5%;
  bottom: 5%;
  margin-left: 18%;
}

.CheckoutProcess {
  padding: 5.8rem 6.4rem;
}

.someContent {
  border: 1px solid red;
}

/* removing for demo purposes
@media screen and (max-width: 768px) {
  .checkoutWrapper {
    display: grid;
    grid-template-columns: 100%;
  }
  img {
    display: none;
  }
  .CheckoutProcess {
    padding: 0;
  }
}
*/

    <Content />

Body:
* {
  margin: 0;
}

.checkoutWrapper {
  display: grid;
  grid-template-columns: 35% 25% 40%; /* create three columns to fit both images  */
}

.coverIMGLast {
  width: calc(100% - 195px); **/* give that illution of real overlapping */**
  height: 100vh; /* please don't delete this line */
  grid-column: 1 / 3; /* overlapping */
  grid-row: 1;
  object-fit: cover;
}
/* this .phone class should be dynamically  located partially on first image */
.phone {
  height: 90vh;
  width: 380px;
  grid-row: 1; /* setting the images on one track / row */
  grid-column: 1/3; /* overlaping */
  justify-self: end;
  transform: translateY(5vh);
}

.CheckoutProcess {
  padding: 5.8rem 0.5rem 6.4rem; /* Add normal padding to give that effect */
}

.someContent {
  border: 1px solid red;
}

@media screen and (max-width: 768px) {
  .checkoutWrapper {
    display: grid;
    grid-template-columns: 100%;
  }

  img {
    display: none;
  }

  .CheckoutProcess {
    padding: 0;
  }
}

<div class="checkoutWrapper">
  <img src="https://via.placeholder.com/300" class="coverIMGLast" />
  <img src="https://via.placeholder.com/300/ff0000" class="phone" />
  <div class="CheckoutProcess">
    <div class="someContent">
      <h1>Some heading</h1>
      <p>
        Some text to go with the paragraph
      </p>
    </div>
  </div>
</div>

https://react-2djy5g-tsheob.stackblitz.io/

As you can see from the above code and link of your edited code.

You just had to make an illusion of the overlapping by using grid-column and playing with the template columns to create a book-like feeling.

with :

grid-template-columns: 35% 25% 40%; /* create three columns to fit both images  */

grid-row: 1;          /* setting the images on one track / row */

grid-column: 1/3;    /* overlaping */

justify-self: end;  /* placing image on the right side of the grid */


问:
How to switch python3 versions on MacOs
I am using python version 3.10.2 but I want to downgrade to 3.9 because it is not compatible with a library in my project. How can I do this with terminal command?

So when I type python3 --version my version is 3.10.2 I want to downgrade it. IDE is pycharm

答:
Install pyenv with Homebrew on macOS:

```<code>brew update
brew install pyenv
</code>```

Define your vitual env variables:

```<code>echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
Restart your shell so the path changes take effect

exec "$SHELL"
</code>```

Check the available python versions:

```<code>pyenv install --list
</code>```

Install the required python version:

```<code>pyenv install 3.9
</code>```

Set it as your global version:

```<code>pyenv global 3.9
</code>```

Title: How to switch python3 versions on MacOs

Body:
Install pyenv with Homebrew on macOS:

brew update
brew install pyenv

Define your vitual env variables:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
Restart your shell so the path changes take effect

exec "$SHELL"

Check the available python versions:

pyenv install --list

Install the required python version:

pyenv install 3.9

Set it as your global version:

pyenv global 3.9


问:
Delete memory of std::map<int, string> completely
I have a map filled with  and now I want to delete the memory completely. How do I do this right? couldn't find anything specific for this topic, sorry if it is already answered...

my code is something like this:

```<code>      for(std::map<short,std::string>::iterator ii=map.begin();
ii!=map.end(); ++ii)
    {
        delete ⅈ
    }
</code>```

But it doesnt work. Can anybody help pls?

regards,
phil

答:
```<code>if(m_mapModels.size() > 0)
{
    for(map<short,std::string>::iterator it=m_mapModels.begin() ; it!=m_mapModels.end() ; it++)
    {
        delete it->second;
    }
    m_mapModels.clear();
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I have a map filled with  and now I want to delete the memory completely. How do I do this right? couldn't find anything specific for this topic, sorry if it is already answered...

my code is something like this:

      for(std::map<short,std::string>::iterator ii=map.begin();
ii!=map.end(); ++ii)
    {
        delete ⅈ
    }

But it doesnt work. Can anybody help pls?

regards,
phil


问:
Spring data jpa: required identifier property not found for class ConnectionManager
I get the error "required identifier property not found for class ConnectionManager" when trying to save a  ConnectionManager class through a CrudRepository in the controller method.

I have a ConnectionManager which has a one to one relationship to a DocumentDetail, and DocumentDetail has a one to many relationship with DocumentValidation.

Hibernate generates the schema from the entities, and I can see an id field in the database. In the console this is the log for creating the connectionManager table.

Hibernate: create table connection_manager (id bigint generated by default as identity, control_id bigint, sequence integer not null, type varchar(255), document_detail_id bigint, email_detail_id bigint, sql_detail_id bigint, primary key (id))

```<code>  @Entity
 public class ConnectionManager {

 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;

 private Long controlId;

private int sequence;

public enum ValidationType {Email, Document, Sql};
@Enumerated(EnumType.STRING)
private ValidationType type;

@OneToOne

@MapsId
private EmailDetail emailDetail;

@OneToOne
@MapsId
private DocumentDetail documentDetail;

@OneToOne

@MapsId
private SqlDetail sqlDetail;

public ConnectionManager(){};
//getters setters
DocumentDetail
</code>```

DocumentDetail

```<code>@Entity
public class DocumentDetail {

 @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy= "documentDetail", cascade = CascadeType.PERSIST)
private List<DocumentValidation> documentValidationList;

private String location;

public DocumentDetail(){};
//getters setters
Document Validation
</code>```

DocumentValidation

```<code>@Entity
public class DocumentValidation {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne
@JoinColumn(name = "documentDetail_id")
private DocumentDetail documentDetail;

private String details;

public DocumentValidation(){}
</code>```

Controller where I create and save the object

```<code>@Controller
public class ConnectionManagerController {

@Autowired
ConnectionManagerService connectionManagerService;

@RequestMapping(value = "/testAdd", method = RequestMethod.GET)
public ResponseEntity<ConnectionManager> testAdd() {
DocumentValidation documentValidation1 = new DocumentValidation();
documentValidation1.setDetails("1st validation for document 1");
DocumentValidation documentValidation2 = new DocumentValidation();
documentValidation2.setDetails("2nd validation for document 1");

ArrayList<DocumentValidation> documentValidationList = new  ArrayList<DocumentValidation>();
documentValidationList.add(documentValidation1);
documentValidationList.add(documentValidation2);

DocumentDetail documentDetail1 = new DocumentDetail();
documentDetail1.setLocation("location of document 1");
documentDetail1.setDocumentValidationList(documentValidationList);

ConnectionManager connectionManager1 = new ConnectionManager();
//connectionManager1.setId((long) 1000);
connectionManager1.setType(ValidationType.Document);
connectionManager1.setDocumentDetail(documentDetail1);
connectionManager1.setControlId((long) 1000);

return new ResponseEntity<ConnectionManager>(connectionManagerService.save(connectionManager1),HttpStatus.OK);
</code>```

}
}

Full stack trace

```<code>            org.springframework.dao.InvalidDataAccessApiUsageException: Required identifier property not found for class com.mycompany.hibernatepoc.ConnectionManager!; nested exception is java.lang.IllegalStateException: Required identifier property not found for class com.mycompany.hibernatepoc.ConnectionManager!
            at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:370)
            at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255)
            at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:527)
            at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
            at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
            at com.sun.proxy.$Proxy165.save(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
            at com.sun.proxy.$Proxy165.save(Unknown Source)
            at com.mycompany.hibernatepoc.ConnectionManagerService.save(ConnectionManagerService.java:18)
            at com.mycompany.hibernatepoc.ConnectionManagerController.testAdd(ConnectionManagerController.java:44)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
            at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
            at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
            at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
            at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
            at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
            at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:645)
            at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
            at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
            at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
            at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at com.mycompany.hibernatepoc.security.jwt.JWTFilter.doFilter(JWTFilter.java:38)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
            at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
            at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
            at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117)
            at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
            at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
            at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
            at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
            at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
            at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
            at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
            at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
            at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
            at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119)
            at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
            at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
            at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
            at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
            at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
            at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
            at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
            at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
            at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
            at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
            at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at java.lang.Thread.run(Thread.java:748)
        Caused by: java.lang.IllegalStateException: Required identifier property not found for class com.mycompany.hibernatepoc.ConnectionManager!
            at org.springframework.data.mapping.PersistentEntity.getRequiredIdProperty(PersistentEntity.java:105)
            at org.springframework.data.relational.core.conversion.AggregateChange.lambda$executeWith$0(AggregateChange.java:86)
            at java.util.ArrayList.forEach(ArrayList.java:1257)
            at org.springframework.data.relational.core.conversion.AggregateChange.executeWith(AggregateChange.java:71)
            at org.springframework.data.jdbc.core.JdbcAggregateTemplate.save(JdbcAggregateTemplate.java:104)
            at org.springframework.data.jdbc.repository.support.SimpleJdbcRepository.save(SimpleJdbcRepository.java:45)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359)
            at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
            at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
            ... 131 common frames omitted
</code>```

答:
In my case for @Id, i have used import javax.persistence.Id; My entity was like below.

```<code>    public class Customer {

    @Id
    @Column(name = "id")
    private Integer id;

    @Column(name = "name")
    private String name;

}
</code>```

Then i added @org.springframework.data.annotation.Id after the @Id like below and it resolved.

```<code>@Id
@org.springframework.data.annotation.Id
@Column(name = "id")
private Integer id;
</code>```

FYI my db related dependencies were spring-boot-starter-data-r2dbc, r2dbc-postgresql, spring-boot-starter-data-jpa, spring-r2dbc, postgresql and r2dbc-spi.

Body:
I get the error "required identifier property not found for class ConnectionManager" when trying to save a  ConnectionManager class through a CrudRepository in the controller method.

I have a ConnectionManager which has a one to one relationship to a DocumentDetail, and DocumentDetail has a one to many relationship with DocumentValidation.

Hibernate generates the schema from the entities, and I can see an id field in the database. In the console this is the log for creating the connectionManager table.

Hibernate: create table connection_manager (id bigint generated by default as identity, control_id bigint, sequence integer not null, type varchar(255), document_detail_id bigint, email_detail_id bigint, sql_detail_id bigint, primary key (id))

  @Entity
 public class ConnectionManager {

 @Id
 @GeneratedValue(strategy = GenerationType.IDENTITY)
 private Long id;

 private Long controlId;

private int sequence;

public enum ValidationType {Email, Document, Sql};
@Enumerated(EnumType.STRING)
private ValidationType type;

@OneToOne

@MapsId
private EmailDetail emailDetail;

@OneToOne
@MapsId
private DocumentDetail documentDetail;

@OneToOne

@MapsId
private SqlDetail sqlDetail;

public ConnectionManager(){};
//getters setters
DocumentDetail

DocumentDetail

@Entity
public class DocumentDetail {

 @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy= "documentDetail", cascade = CascadeType.PERSIST)
private List<DocumentValidation> documentValidationList;

private String location;

public DocumentDetail(){};
//getters setters
Document Validation

DocumentValidation

@Entity
public class DocumentValidation {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne
@JoinColumn(name = "documentDetail_id")
private DocumentDetail documentDetail;

private String details;

public DocumentValidation(){}

Controller where I create and save the object

@Controller
public class ConnectionManagerController {

@Autowired
ConnectionManagerService connectionManagerService;

@RequestMapping(value = "/testAdd", method = RequestMethod.GET)
public ResponseEntity<ConnectionManager> testAdd() {
DocumentValidation documentValidation1 = new DocumentValidation();
documentValidation1.setDetails("1st validation for document 1");
DocumentValidation documentValidation2 = new DocumentValidation();
documentValidation2.setDetails("2nd validation for document 1");

ArrayList<DocumentValidation> documentValidationList = new  ArrayList<DocumentValidation>();
documentValidationList.add(documentValidation1);
documentValidationList.add(documentValidation2);

DocumentDetail documentDetail1 = new DocumentDetail();
documentDetail1.setLocation("location of document 1");
documentDetail1.setDocumentValidationList(documentValidationList);

ConnectionManager connectionManager1 = new ConnectionManager();
//connectionManager1.setId((long) 1000);
connectionManager1.setType(ValidationType.Document);
connectionManager1.setDocumentDetail(documentDetail1);
connectionManager1.setControlId((long) 1000);

return new ResponseEntity<ConnectionManager>(connectionManagerService.save(connectionManager1),HttpStatus.OK);

}
}

Full stack trace

            org.springframework.dao.InvalidDataAccessApiUsageException: Required identifier property not found for class com.mycompany.hibernatepoc.ConnectionManager!; nested exception is java.lang.IllegalStateException: Required identifier property not found for class com.mycompany.hibernatepoc.ConnectionManager!
            at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:370)
            at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255)
            at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:527)
            at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
            at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
            at com.sun.proxy.$Proxy165.save(Unknown Source)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
            at com.sun.proxy.$Proxy165.save(Unknown Source)
            at com.mycompany.hibernatepoc.ConnectionManagerService.save(ConnectionManagerService.java:18)
            at com.mycompany.hibernatepoc.ConnectionManagerController.testAdd(ConnectionManagerController.java:44)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
            at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
            at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
            at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)
            at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)
            at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
            at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
            at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
            at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
            at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:645)
            at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:750)
            at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
            at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
            at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at com.mycompany.hibernatepoc.security.jwt.JWTFilter.doFilter(JWTFilter.java:38)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
            at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
            at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
            at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357)
            at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117)
            at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
            at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
            at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
            at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
            at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
            at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
            at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
            at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
            at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
            at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
            at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
            at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
            at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
            at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
            at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119)
            at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
            at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
            at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
            at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
            at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
            at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
            at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
            at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
            at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
            at io.undertow.server.Connectors.executeRootHandler(Connectors.java:364)
            at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at java.lang.Thread.run(Thread.java:748)
        Caused by: java.lang.IllegalStateException: Required identifier property not found for class com.mycompany.hibernatepoc.ConnectionManager!
            at org.springframework.data.mapping.PersistentEntity.getRequiredIdProperty(PersistentEntity.java:105)
            at org.springframework.data.relational.core.conversion.AggregateChange.lambda$executeWith$0(AggregateChange.java:86)
            at java.util.ArrayList.forEach(ArrayList.java:1257)
            at org.springframework.data.relational.core.conversion.AggregateChange.executeWith(AggregateChange.java:71)
            at org.springframework.data.jdbc.core.JdbcAggregateTemplate.save(JdbcAggregateTemplate.java:104)
            at org.springframework.data.jdbc.repository.support.SimpleJdbcRepository.save(SimpleJdbcRepository.java:45)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359)
            at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
            at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
            at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
            at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
            ... 131 common frames omitted

Body:
In my case for @Id, i have used import javax.persistence.Id; My entity was like below.

    public class Customer {

    @Id
    @Column(name = "id")
    private Integer id;

    @Column(name = "name")
    private String name;

}

Then i added @org.springframework.data.annotation.Id after the @Id like below and it resolved.

@Id
@org.springframework.data.annotation.Id
@Column(name = "id")
private Integer id;

FYI my db related dependencies were spring-boot-starter-data-r2dbc, r2dbc-postgresql, spring-boot-starter-data-jpa, spring-r2dbc, postgresql and r2dbc-spi.


问:
Get text from tree structure SQL
i have category table with tree structure

every row has text for description Like below:

nodeid
parentid
description

1
0
root description

2
1
sub category description

3
2

4
3

5
4
last description

I want to show all the description from the root to the last category, like below:

Description:

root description.

sub category description.

last description

how can I do this?

thanks a lot

答:
Here is the SQL (MS SQLServer) dbfiddle link:

```<code>WITH q
AS
(
  select nodeid,parentid,description from category where parentid=0
  union all
  select c.nodeid,c.parentid,c.description from category c inner join  q on q.nodeid=c.parentid
)
select description from q where description is not null;
</code>```

PostgreSQL : dbfiddle link

Oracle : dbfiddle link

Title: Get text from tree structure SQL

Body:
Here is the SQL (MS SQLServer) dbfiddle link:

WITH q
AS
(
  select nodeid,parentid,description from category where parentid=0
  union all
  select c.nodeid,c.parentid,c.description from category c inner join  q on q.nodeid=c.parentid
)
select description from q where description is not null;

PostgreSQL : dbfiddle link

Oracle : dbfiddle link


问:
How to find DIV inside div-structure by InnerText or Class
I have a div with multiple children which have a large div structure in them. Now I want to find an element with an specific innerText.
How can I do this?
I have heard something from document.evaluate but is this the right thing?

First Label

Second Label

Third Label

```

I have main and want to find the Label with the text Second Label without multiple Loops.

答:
Using an XPath expression in Javascript  you can query for the specific element and use text() to query the text within the element.

const getnodes = function(expr, parent) {
  let results = [];
  let contextNode = parent || document;
  let query = document.evaluate(expr, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  for (let i = 0, length = query.snapshotLength; i < length; ++i) {
    results.push(query.snapshotItem(i));
  }
  return results;
};

let col = getnodes('//div[@class="main"]//label/text()[ contains(.,"Second Label") ]');
col.forEach(n => {
  console.log(n.textContent)
});

let ref=document.querySelector('div.main > div.child3');

col=getnodes('div/div/label',ref);
col.forEach(n => {
  console.log('Using explicit reference node:',n.textContent)
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="main">
  <div class="child1">
    <div>
      <div><label class="text1">First Label</label></div>
    </div>
  </div>
  <div class="child2">
    <div>
      <div><label class="text2">Second Label</label></div>
    </div>
  </div>
  <div class="child3">
    <div>
      <div><label class="text3">Third Label</label></div>
    </div>
  </div>
</div></code>```

Body:
I have a div with multiple children which have a large div structure in them. Now I want to find an element with an specific innerText.
How can I do this?
I have heard something from document.evaluate but is this the right thing?

First Label

Second Label

Third Label

I have main and want to find the Label with the text Second Label without multiple Loops.

Body:
Using an XPath expression in Javascript  you can query for the specific element and use text() to query the text within the element.

const getnodes = function(expr, parent) {
  let results = [];
  let contextNode = parent || document;
  let query = document.evaluate(expr, contextNode, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  for (let i = 0, length = query.snapshotLength; i < length; ++i) {
    results.push(query.snapshotItem(i));
  }
  return results;
};

let col = getnodes('//div[@class="main"]//label/text()[ contains(.,"Second Label") ]');
col.forEach(n => {
  console.log(n.textContent)
});

let ref=document.querySelector('div.main > div.child3');

col=getnodes('div/div/label',ref);
col.forEach(n => {
  console.log('Using explicit reference node:',n.textContent)
});

<div class="main">
  <div class="child1">
    <div>
      <div><label class="text1">First Label</label></div>
    </div>
  </div>
  <div class="child2">
    <div>
      <div><label class="text2">Second Label</label></div>
    </div>
  </div>
  <div class="child3">
    <div>
      <div><label class="text3">Third Label</label></div>
    </div>
  </div>
</div>


问:
Upload file to Google Drive with Requests in Python
I'm struggling to correctly upload a file to Google Drive through their API. I'm using Python and I'm aware that there is a client library for Google's API. Here is what I currently have. When running the below code, an empty untitled document is created in Google Drive and it's not in the correct directory, root/level_1. I'm not sure what I'm doing wrong with the data and files object. Is there anything that stands out from the code?

Here are the docs that I was following.

```<code>import json
import requests

url = "https://www.googleapis.com/upload/drive/v2/files?access_token=ACCESS_TOKEN&uploadType=multipart"
files = {"file": requests.get("image_url").content}
data = {
    "title": "image_url.jpg",
    "parents": ["root", "level_1"]
}

response = requests.post(url, data=json.dumps(data), files=files)
# json.loads(response.text)["title"] = "Untitled"
return response
</code>```

答:
```<code>import requests
f = open("img.png", "r")
files = {
  "metadata": ("",'{"name": "rhondu.png"}', 'application/json'),
    'laadu': ('', open('img.png', 'rb'), 'image/png')
}
file = [("",'{"name": "rhondu420.png"}', 'application/json'), ('', open('img.png', 'rb'), 'image/png', {'Expires': '0'})]
url = "https://www.googleapis.com/upload/drive/v3/files?access_token=ya29.A0ARrdaM8rd7nXLkz39QxqZOJp_DyVqAkQ98WErWhkuBmsihgFIGQ6TKF5YvWmtamWZXVqQD_Ey10hVy-5nsJskibD7-5obCOvDzySMlhXInFIHzHWJrONHXpO-l8JQ6UODgxHJermFEbvpAC20WMX5mPRAqRxoA"``
res = requests.post(url, files=files)
print(res.text) (edited)
</code>```

Body:
I'm struggling to correctly upload a file to Google Drive through their API. I'm using Python and I'm aware that there is a client library for Google's API. Here is what I currently have. When running the below code, an empty untitled document is created in Google Drive and it's not in the correct directory, root/level_1. I'm not sure what I'm doing wrong with the data and files object. Is there anything that stands out from the code?

Here are the docs that I was following.

import json
import requests

url = "https://www.googleapis.com/upload/drive/v2/files?access_token=ACCESS_TOKEN&uploadType=multipart"
files = {"file": requests.get("image_url").content}
data = {
    "title": "image_url.jpg",
    "parents": ["root", "level_1"]
}

response = requests.post(url, data=json.dumps(data), files=files)
# json.loads(response.text)["title"] = "Untitled"
return response


问:
Next.js production build doesn't apply css variables
I have the next postcss config

```<code>module.exports = {
  plugins: [
    [
      'postcss-preset-env',
      {
        browsers: 'last 2 versions, IE 11, not dead',
        preserve: false,
        features: {
          'custom-media-queries': true,
          'custom-properties': true,
          'nesting-rules': true
        },
        importFrom: ['src/styles/variables.css']
      }
    ]
  ]
}

</code>```

And this file with css variables

```<code>@custom-media --desktop screen and (min-width: 768px);
@custom-media --mobile screen and (max-width: 767px);

:root {
  --montserrat: montserrat, sans-serif;
  --sfProDisplay: sf pro display, sans-serif;
  --helvetica: helvetica, sans-serif;
  --blue: #315efb;
  --middleBlue: #2c54e2;
  --darkBlue: #274bc8;
  --lightBlue: #e0ebff;
  --green: #21a038;
  --grey: #62687f;
  --darkGray: #343b4c;
  --blueGray: #8d96b2;
  --cloudGray: #f3f4f7;
  --cloudGray7: #afb6c9;
  --darkCarbone: #1f2431;
  --paleYellow: #fffde5;
  --red: #ff564e;
}

</code>```

After i built my project via next build && next export, colors are not displayed correctly. For example, color: var(--blueGray), instead color: #8d96b2. Has anybody idea what's wrong?

答:
This may not be worth the bounty but from NextJS docs.

CSS variables are not compiled because it is not possible to safely do
so. If you must use variables, consider using something like Sass
variables which are compiled away by Sass.

Body:
I have the next postcss config

module.exports = {
  plugins: [
    [
      'postcss-preset-env',
      {
        browsers: 'last 2 versions, IE 11, not dead',
        preserve: false,
        features: {
          'custom-media-queries': true,
          'custom-properties': true,
          'nesting-rules': true
        },
        importFrom: ['src/styles/variables.css']
      }
    ]
  ]
}

And this file with css variables

@custom-media --desktop screen and (min-width: 768px);
@custom-media --mobile screen and (max-width: 767px);

:root {
  --montserrat: montserrat, sans-serif;
  --sfProDisplay: sf pro display, sans-serif;
  --helvetica: helvetica, sans-serif;
  --blue: #315efb;
  --middleBlue: #2c54e2;
  --darkBlue: #274bc8;
  --lightBlue: #e0ebff;
  --green: #21a038;
  --grey: #62687f;
  --darkGray: #343b4c;
  --blueGray: #8d96b2;
  --cloudGray: #f3f4f7;
  --cloudGray7: #afb6c9;
  --darkCarbone: #1f2431;
  --paleYellow: #fffde5;
  --red: #ff564e;
}

After i built my project via next build && next export, colors are not displayed correctly. For example, color: var(--blueGray), instead color: #8d96b2. Has anybody idea what's wrong?


问:
How can I get current user's JWT informations?
I'm trying the get all orders that belonging the user that already login to the system.

I want to get the id information of the current user with the get() method below and get the order information belonging to current user from the order table.
My goal is to get the current user's id from the JWT token using flask-jwt-extended.

How can I do that?

```<code>@api.route('/orders')
@jwt_required()
def get(self):
   # current_user_info
   user_id = current_user_info["id"]
   return UserService.get_orders(user_id)

</code>```

答:
flask_jwt_extended provides the get_jwt_identity() function, which returns the identity used to create the token used in the current call: create_access_token(identity=username).

Link to the documentation

So in your case, it should become something like this

```<code>@api.route('/orders')
@jwt_required()
def get(self):
   # current_user_info
   user_id = get_jwt_identity()
   return UserService.get_orders(user_id)
</code>```

Body:
I'm trying the get all orders that belonging the user that already login to the system.

I want to get the id information of the current user with the get() method below and get the order information belonging to current user from the order table.
My goal is to get the current user's id from the JWT token using flask-jwt-extended.

How can I do that?

@api.route('/orders')
@jwt_required()
def get(self):
   # current_user_info
   user_id = current_user_info["id"]
   return UserService.get_orders(user_id)

Body:
flask_jwt_extended provides the get_jwt_identity() function, which returns the identity used to create the token used in the current call: create_access_token(identity=username).

Link to the documentation

So in your case, it should become something like this

@api.route('/orders')
@jwt_required()
def get(self):
   # current_user_info
   user_id = get_jwt_identity()
   return UserService.get_orders(user_id)


问:
How to change color based on theme flutter
I'm trying to change my container's color based on the system theme mode. Is there a way to change it using conditional if?

Here is the code:

```<code>     Container(
            color: //this is what I'm trying to change based on the theme,
            padding: EdgeInsets.only(right: 10, left: 10, top: 7, bottom: 25),
            child: Row(
              children: [
                Flexible(
                          ...
</code>```

And this is my theme_provider:

```<code>class MyThemes {
  static final darkTheme = ThemeData(
    ...
  );

  static final lightTheme = ThemeData(
    ...
  );
}
</code>```

答:
Use color: Theme.of(context).colorScheme.colorName

 Container(
     color: Theme.of(context).colorScheme.primary,//replace primary with your colorName
```

More about using theme.

Body:
I'm trying to change my container's color based on the system theme mode. Is there a way to change it using conditional if?

Here is the code:

     Container(
            color: //this is what I'm trying to change based on the theme,
            padding: EdgeInsets.only(right: 10, left: 10, top: 7, bottom: 25),
            child: Row(
              children: [
                Flexible(
                          ...

And this is my theme_provider:

class MyThemes {
  static final darkTheme = ThemeData(
    ...
  );

  static final lightTheme = ThemeData(
    ...
  );
}

Body:
Use color: Theme.of(context).colorScheme.colorName

 Container(
     color: Theme.of(context).colorScheme.primary,//replace primary with your colorName

More about using theme.


问:
Deserialize XML containing Properties and Values with Jackson
I'm trying to deserialize the following XML.

```<code><RESPONSE>
    <FIELDS>
        <FIELD KEY="MSG_VERSION">003</FIELD>
        <FIELD KEY="CUSTOMER_NBR">001</FIELD>
        ...
        <FIELD KEY="ORIGINAL_TYPE">RM1</FIELD>
    </FIELDS>
</RESPONSE>
</code>```

I need to capture the values from KEY properties and the values. Following is the Java class I have created.

```<code>package io.app.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JacksonXmlRootElement(localName = "RESPONSE")
public class ResponseData {
    @JacksonXmlElementWrapper(localName = "FIELDS")
    @JacksonXmlProperty(localName = "FIELD")
    private List<Field> fields = new ArrayList<>();
    @Data
    public static class Field {
        @JacksonXmlProperty(isAttribute = true)
        private String key;
        @JacksonXmlText(value = true)
        private String content;
    }
}
</code>```

The XmlMapper has been initialized as follows.

```<code>private final XmlMapper xmlMapper = new XmlMapper();

xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
</code>```

The issue is that, although the content is properly getting set, the key value is always null. What am I doing wrong here?

答:
As @Thomas pointed out in a comment on the post, it was the case of the property that was causing the issue.

```<code>@JacksonXmlProperty(isAttribute = true, localName = "KEY")
private String key;
</code>```

This was the fix.

Body:
I'm trying to deserialize the following XML.

<RESPONSE>
    <FIELDS>
        <FIELD KEY="MSG_VERSION">003</FIELD>
        <FIELD KEY="CUSTOMER_NBR">001</FIELD>
        ...
        <FIELD KEY="ORIGINAL_TYPE">RM1</FIELD>
    </FIELDS>
</RESPONSE>

I need to capture the values from KEY properties and the values. Following is the Java class I have created.

package io.app.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JacksonXmlRootElement(localName = "RESPONSE")
public class ResponseData {
    @JacksonXmlElementWrapper(localName = "FIELDS")
    @JacksonXmlProperty(localName = "FIELD")
    private List<Field> fields = new ArrayList<>();
    @Data
    public static class Field {
        @JacksonXmlProperty(isAttribute = true)
        private String key;
        @JacksonXmlText(value = true)
        private String content;
    }
}

The XmlMapper has been initialized as follows.

private final XmlMapper xmlMapper = new XmlMapper();

xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);

The issue is that, although the content is properly getting set, the key value is always null. What am I doing wrong here?

Body:
As @Thomas pointed out in a comment on the post, it was the case of the property that was causing the issue.

@JacksonXmlProperty(isAttribute = true, localName = "KEY")
private String key;

This was the fix.


问:
Cannot find module 'axios'
I am coding a small program for Firebase Functions, using node.js.  I always install my node modules using npm and i also installed axios using npm only.

However when I do firebase deploy I get this error:

This is my package-lock.json

```<code>{
  "requires": true,
  "lockfileVersion": 1,
  "dependencies": {
    "axios": {
      "version": "0.19.0",
      "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
      "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
      "requires": {
        "follow-redirects": "1.5.10",
        "is-buffer": "^2.0.2"
      }
    },
    "debug": {
      "version": "3.1.0",
      "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
      "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
      "requires": {
        "ms": "2.0.0"
      }
    },
    "follow-redirects": {
      "version": "1.5.10",
      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
      "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
      "requires": {
        "debug": "=3.1.0"
      }
    },
    "is-buffer": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
      "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
    },
    "ms": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
      "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
    }
  }
}
</code>```

When I remove const axios = require('axios'); from my index.js, the rest of my code compiles and works just fine.

Any idea what is going on?

Thank you!

答: Command prompt then go to your folder and npm install axios. Finally, run the code. It worked for me</p>

Title: Cannot find module 'axios'

Body:
I am coding a small program for Firebase Functions, using node.js.  I always install my node modules using npm and i also installed axios using npm only.

However when I do firebase deploy I get this error:

This is my package-lock.json

{
  "requires": true,
  "lockfileVersion": 1,
  "dependencies": {
    "axios": {
      "version": "0.19.0",
      "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
      "integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
      "requires": {
        "follow-redirects": "1.5.10",
        "is-buffer": "^2.0.2"
      }
    },
    "debug": {
      "version": "3.1.0",
      "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
      "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
      "requires": {
        "ms": "2.0.0"
      }
    },
    "follow-redirects": {
      "version": "1.5.10",
      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
      "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
      "requires": {
        "debug": "=3.1.0"
      }
    },
    "is-buffer": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
      "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
    },
    "ms": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
      "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
    }
  }
}

When I remove const axios = require('axios'); from my index.js, the rest of my code compiles and works just fine.

Any idea what is going on?

Thank you!


问:
Why am I getting an invalid literal error?
I need to split a two digit value from a pyqt spinbox in half for math operations. In order to do this I'm converting the value to a string. This works fine for the first digit and it goes back to an integer without a problem. The second digit however won't convert back and keeps throwing a base 10 invalid literal error. What am I doing wrong? I have the decimal place set to 0 so I don't think it's that.</p>

```<code>         w1 = self.doubleSpinBox_12.value()
         w2 = self.doubleSpinBox_13.value()

         w1a = str(w1)
         w1b = w1a[:1]
         w1c = int( w1b) * 12

         w1b2 = w1a[1:]
         w1b3 = int( w1b2)

         w = w1c + w1b3
         print w
</code>```

答:
To find out what's going on throw some prints in there:

```<code>w1b2 = w1a[1:]
print(repr(w1b2))
</code>```

then you can see exactly what's in there, including whatever characters are not base 10 valid literals.

Body:
I need to split a two digit value from a pyqt spinbox in half for math operations. In order to do this I'm converting the value to a string. This works fine for the first digit and it goes back to an integer without a problem. The second digit however won't convert back and keeps throwing a base 10 invalid literal error. What am I doing wrong? I have the decimal place set to 0 so I don't think it's that.

         w1 = self.doubleSpinBox_12.value()
         w2 = self.doubleSpinBox_13.value()

         w1a = str(w1)
         w1b = w1a[:1]
         w1c = int( w1b) * 12

         w1b2 = w1a[1:]
         w1b3 = int( w1b2)

         w = w1c + w1b3
         print w

Body:
To find out what's going on throw some prints in there:

w1b2 = w1a[1:]
print(repr(w1b2))

then you can see exactly what's in there, including whatever characters are not base 10 valid literals.


问:
Creating a flying object that detects impact with a fixed object in Roblox
I'm attempting to create a flying object that can essentially be trapped by another object placed in its path.  I'm having trouble with the hit/touch detection.

For the flying object, we'll call "bug", I've created an model with a PrimaryPart named "Primary", and the Primary part has "CanCollide", "CanTouch", and "Anchored" set to true.

When I run the following script with the above settings, things look like I'd expect, and I can see log entries whenever the bug touches my character, but I don't see when the bug touches my net object.  My understanding is that because both objects are "Anchored", collision detection isn't supported (even though one is the bug that moves around).  When I uncheck "Anchored" for the net, it falls down.  When I uncheck "Anchored" for the bug, it flies erratically and disappears.  Is there a way I can unanchor the bug, but still keep it under control, flying where its told until it is caught?

```<code>local TweenService = game:GetService("TweenService")
local bugAnchor = script.Parent.Parent.BugAnchor
local bug = script.Parent.PrimaryPart

local function onBugTouched(part)
    if part:IsDescendantOf(bug) then return end
    print(bug:GetFullName() .. " was touched by " .. part:GetFullName())
end

local function randomGoal(anchor)
    local random = Random.new()
    local randomX = random:NextNumber(-30, 30)
    local randomY = random:NextNumber(-15, 15)
    local randomZ = random:NextNumber(-30, 30)
    return anchor.Position + Vector3.new(randomX, randomY, randomZ)
end

bug.Touched:connect(onBugTouched)
while true do
    wait(1)
    local goal = randomGoal(bugAnchor)
    local move = TweenService:Create(bug, TweenInfo.new(), {Position = goal})
    bug.CFrame = CFrame.lookAt(bug.Position,(goal))
    move:play()
end
</code>```

答:
Two anchored objects cannot fire the Touched event on each other as the movement causing a collision must result from a physics movement. Altering the CFrame manually won't do that and achnored parts are not affected by physics.

If you unanchor the bug it will be affected by gravity which might explain the observed "erratical" movements.

You could disable gravity or to make the bug fly by appling an upward force to it that overcomes gravity.

Alternatively you can manually check wether parts touch using https://developer.roblox.com/en-us/api-reference/function/BasePart/GetTouchingParts

I'm sure you'll find more options if you dig through the manual.

Body:
I'm attempting to create a flying object that can essentially be trapped by another object placed in its path.  I'm having trouble with the hit/touch detection.

For the flying object, we'll call "bug", I've created an model with a PrimaryPart named "Primary", and the Primary part has "CanCollide", "CanTouch", and "Anchored" set to true.

When I run the following script with the above settings, things look like I'd expect, and I can see log entries whenever the bug touches my character, but I don't see when the bug touches my net object.  My understanding is that because both objects are "Anchored", collision detection isn't supported (even though one is the bug that moves around).  When I uncheck "Anchored" for the net, it falls down.  When I uncheck "Anchored" for the bug, it flies erratically and disappears.  Is there a way I can unanchor the bug, but still keep it under control, flying where its told until it is caught?

local TweenService = game:GetService("TweenService")
local bugAnchor = script.Parent.Parent.BugAnchor
local bug = script.Parent.PrimaryPart

local function onBugTouched(part)
    if part:IsDescendantOf(bug) then return end
    print(bug:GetFullName() .. " was touched by " .. part:GetFullName())
end

local function randomGoal(anchor)
    local random = Random.new()
    local randomX = random:NextNumber(-30, 30)
    local randomY = random:NextNumber(-15, 15)
    local randomZ = random:NextNumber(-30, 30)
    return anchor.Position + Vector3.new(randomX, randomY, randomZ)
end

bug.Touched:connect(onBugTouched)
while true do
    wait(1)
    local goal = randomGoal(bugAnchor)
    local move = TweenService:Create(bug, TweenInfo.new(), {Position = goal})
    bug.CFrame = CFrame.lookAt(bug.Position,(goal))
    move:play()
end


问:
How to insert element at the beginning of a slice?
I have a slice:

```<code>mySlice := []int{4,5,6,7}
myelement := 3
</code>```

I want to insert myelement at index 0 so that my output will be [3,4,5,6,7].

How can I do that?

答:
```<code>func addFirst(s []int, insertValue int) []int {
   res := make([]int, len(s)+1)
   copy(res[1:], s)
   res[0] = insertValue
   return res
}
</code>```

Another solution, former answers are better.

Body:
I have a slice:

mySlice := []int{4,5,6,7}
myelement := 3

I want to insert myelement at index 0 so that my output will be [3,4,5,6,7].

How can I do that?

Body:
func addFirst(s []int, insertValue int) []int {
   res := make([]int, len(s)+1)
   copy(res[1:], s)
   res[0] = insertValue
   return res
}

Another solution, former answers are better.


问:
Modify large string
I have a large string in the following format -

```<code>   <a href="12345.html"><a href="12345.html"><a href="12345.html"><a href="12345.html">
   <a href="12345.html"><a href="12345.html"><a href="12345.html"><a href="12345.html">
</code>```

Id like to store all occurances of the value that occurs before .html. So above html becomes something like 12345.html,12345.html,12345.html,12345.html,12345.html,12345.html,12345.html,12345.html

Do I need a regular expression? or some kind of replace method.

Thanks

答:
You don't actually need a regular expression, but you could use the underlying Matcher class:

```<code>final String searchString = "12345.html";
final String txt =
"<a href=\"12345.html\"><a href=\"12345.html\"><a href=\"12345.html\"><a href=\"12345.html\">\n"
+ "<a href=\"12345.html\"><a href=\"12345.html\"><a href=\"12345.html\"><a href=\"12345.html\">";
final Matcher matcher = Pattern.compile(searchString, Pattern.LITERAL).matcher(txt);
final StringBuilder sb = new StringBuilder();
while(matcher.find()){
    if(sb.length() > 0) sb.append(',');
    sb.append(matcher.group());
}
System.out.println(sb.toString());
</code>```

Output:

12345.html,12345.html,12345.html,12345.html,12345.html,12345.html,12345.html,12345.html

Title: Modify large string

Body:
I have a large string in the following format -

Id like to store all occurances of the value that occurs before .html. So above html becomes something like 12345.html,12345.html,12345.html,12345.html,12345.html,12345.html,12345.html,12345.html

Do I need a regular expression? or some kind of replace method.

Thanks

Body:
You don't actually need a regular expression, but you could use the underlying Matcher class:

final String searchString = "12345.html";
final String txt =
"<a href=\"12345.html\"><a href=\"12345.html\"><a href=\"12345.html\"><a href=\"12345.html\">\n"
+ "<a href=\"12345.html\"><a href=\"12345.html\"><a href=\"12345.html\"><a href=\"12345.html\">";
final Matcher matcher = Pattern.compile(searchString, Pattern.LITERAL).matcher(txt);
final StringBuilder sb = new StringBuilder();
while(matcher.find()){
    if(sb.length() > 0) sb.append(',');
    sb.append(matcher.group());
}
System.out.println(sb.toString());

Output:

12345.html,12345.html,12345.html,12345.html,12345.html,12345.html,12345.html,12345.html


问:
how to upgrade next month last day of variable in mysql stored procedure?
```<code>In my while loop procedure (IN start_date date)
DECLARE data_date date;
set data_date=start_date;

while data_date<end_date do
    insert into t1
    ……
    where date=data_date

    set data_date=SELECT LAST_DAY(data_date + INTERVAL 1 MONTH);
</code>```

It gets wrong because set data_date=SELECT LAST_DAY(data_date + INTERVAL 1 MONTH); but it works SELECT LAST_DAY(data_date + INTERVAL 1 MONTH)  out of the procedure. How can I upgrade my data_date variable based on select last_day(……) method.

答: SELECT LAST_DAY(data_date + INTERVAL 1 MONTH) into data_date works.

Body:
In my while loop procedure (IN start_date date)
DECLARE data_date date;
set data_date=start_date;

while data_date<end_date do
    insert into t1
    ……
    where date=data_date

    set data_date=SELECT LAST_DAY(data_date + INTERVAL 1 MONTH);

It gets wrong because set data_date=SELECT LAST_DAY(data_date + INTERVAL 1 MONTH); but it works SELECT LAST_DAY(data_date + INTERVAL 1 MONTH)  out of the procedure. How can I upgrade my data_date variable based on select last_day(……) method.


问:
How can I execute this function for range of values?
I have this function

where f has values (18 19 20 21 22), and I should compute the value of the function for each value of f and plot each value.
I try to make f as vector 18:22, but it gives result from 1 to 22. Same result when I use for loop. My code is below, how can I modify it to take the values within the range only?

```<code>clc
fc=20;
theta=80;
N=16;
f=18:22;
g_m(f)=(sin((N*pi/2).*sin(theta).*(f/fc-1)))./sqrt(N).*(sin(pi/2).*(f/fc-1));
g_p(f)=exp(1j*0.5*(N-1).*pi*sin(theta).*(f/fc-1));
gain(f)=g_m(f).*g_p(f);
figure(1);
plot(f,g_m(f));
</code>```

答:
I believe this should give you enough information:</p>
```<code>f = 5:7;
g(f)= [2, 2, 5]
g =
   0   0   0   0   2   2   5
</code>```

Body:
I have this function

where f has values (18 19 20 21 22), and I should compute the value of the function for each value of f and plot each value.
I try to make f as vector 18:22, but it gives result from 1 to 22. Same result when I use for loop. My code is below, how can I modify it to take the values within the range only?

clc
fc=20;
theta=80;
N=16;
f=18:22;
g_m(f)=(sin((N*pi/2).*sin(theta).*(f/fc-1)))./sqrt(N).*(sin(pi/2).*(f/fc-1));
g_p(f)=exp(1j*0.5*(N-1).*pi*sin(theta).*(f/fc-1));
gain(f)=g_m(f).*g_p(f);
figure(1);
plot(f,g_m(f));

Body:
I believe this should give you enough information:

f = 5:7;
g(f)= [2, 2, 5]
g =
   0   0   0   0   2   2   5


问:
What is an annotated dataframe really?
I'm a new SO user but also new(-ish) at R. I've recently encountered annotated dataframes. I've tried to do my due diligence in searching for a good explanation and I have read the following about Annotated DataFrames https://www.rdocumentation.org/packages/Biobase/versions/2.32.0/topics/AnnotatedDataFrame. But I don't get what an AnnotatedDataFrame is.

Is it effectively a list of two dataframes (one metadata and the other data)?

Apologies for the annoying question, but it's not clear to me what I'm working with. Any clarification is appreciated. Thank you!

答:
as you have read the documentation,

Description. An AnnotatedDataFrame consists of two parts. There is a
collection of samples and the values of variables measured on those
samples. There is also a description of each variable measured. The
components of an AnnotatedDataFrame can be accessed with pData and
varMetadata .

Annotation-dataframe is basically the concept we use in data manipulation, I mention an example and I hope it will get clear for you.

Imagine you have 10 articles(of a website) and you want to do analysis on them, like finding how many nouns are used for each word in each article, how many adjectives and so on. so first you separate each word from articles and put them in their designated rows, then what? then you have a list of words but you need to map them to a field that works as meta so that you can run a trained machine learning model on those to know which words are what, in preparation of doing that you need to convert your data into a data that is now annotated which we call Annotated-Dataframe.

Title: What is an annotated dataframe really?


问:
Laravel model get all results, but if model has relation then check for certain condition
Assume I have book models and borrow models. They are one-to-many relationships. I want to get a collection of all the books but return the result if the book is borrowed within the current week. But if it's not, then don't display. I've been trying whereHas(), but I think it didn't suit what I'm looking for.</p>
```<code>$displayed_books = Books::orderBy('updated_at', 'DESC')
    ->ifHasborrow('borrow', function ($query) {
        $query->where('start_date', '>=', currentweek())
            ->where('end_date', "<=", currentweek());
    })
</code>```

答:
```<code>$displayedBooks = Books::orderBy('updated_at', 'DESC')
    ->where(function ($query) {
        $query->whereHas('borrow', function($query) {
            $now = Carbon::now();
            $query->where([
                ['start_date', '>=', $now->startOfWeek()],
                ['end_date', '<=', $now->endOfWeek()]
            ]);
        $query->orWhereDoesntHave('borrow');
    })
})->get();
</code>```

Body:
Assume I have book models and borrow models. They are one-to-many relationships. I want to get a collection of all the books but return the result if the book is borrowed within the current week. But if it's not, then don't display. I've been trying whereHas(), but I think it didn't suit what I'm looking for.

$displayed_books = Books::orderBy('updated_at', 'DESC')
    ->ifHasborrow('borrow', function ($query) {
        $query->where('start_date', '>=', currentweek())
            ->where('end_date', "<=", currentweek());
    })