问:
Cannot fix JAVA_HOME environment variable
I am trying to fix Java for projects I am working on on my local computer. I had jenv installed to switch between versions more easily, but at some point over the last couple of days I must have done something and messed up my JAVA_HOME environment variable and now I can't seem to fix it.

I use zsh, and I am on a Mac running MacOS Monterey 12.2. I first tried uninstalling jenv (brew uninstall jenv - just wasn't really using it and seemed to be making things more confusing to solve this issue). Even though I did that and took jenv out of my $PATH variable, whenever I run almost any command in the terminal the statement "jenv:11: command not found: jenv" prints. I'm not sure if that is a lesser issue, but something that probably needs to be solved.

My bigger issue is fixing Java on my machine. Up until a couple days ago this was not an issue, but now if I try to set JAVA_HOME in my .zshrc file like this

export JAVA_HOME=$(/Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home)

and run source ~/.zshrc I get the message:

/Users/[user-name]/.zshrc:119: permission denied: /Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home

This happens no matter which Java version I try to set JAVA_HOME to. My Java installation directories and versions are as follows:

```<code># dir - /Library/Java/JavaVirtualMachines
drwxr-xr-x  3 root  wheel   96 Apr 20  2021 adoptopenjdk-8.jdk
drwxr-xr-x  3 root  wheel   96 Oct 19 08:54 temurin-11.jdk

# dir - /Users/[user-name]/Library/Java/JavaVirtualMachines
drwxr-xr-x  3 [user-name]  staff   96 Dec 10 11:36 corretto-11.0.17
drwxr-xr-x  3 [user-name]  staff   96 Sep 30 09:56 corretto-17.0.4.1
</code>```

Running /usr/libexec/java_home -V prints the following:

```<code>Matching Java Virtual Machines (4):
    17.0.4 (x86_64) "Amazon.com Inc." - "Amazon Corretto 17" /Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-17.0.4.1/Contents/Home
    11.0.17 (x86_64) "Amazon.com Inc." - "Amazon Corretto 11" /Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home
    11.0.17 (x86_64) "Eclipse Adoptium" - "OpenJDK 11.0.17" /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
    1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
/Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-17.0.4.1/Contents/Home
</code>```

If I run echo $JAVA_HOME, a blank line prints followed by jenv:11: command not found: jenv.

I tried to run unset JAVA_HOME, followed by either:

export JAVA_HOME=/Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home

or

export JAVA_HOME=$(/Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home)

and don't get a permission denied error, only the jenv:11: command not found: jenv complaint. But after, if I run echo $JAVA_HOME, I still get a blank line followed by the jenv complaint.

It seems like no matter what I do, something keeps preventing me from setting JAVA_HOME.

Out of desperation, I ran mod 777 ~/.zshrc, and also checked System Preferences -> Security and Privacy -> Full Disk Access and made sure that iTerm was checked in that list, and to check my user permissions I ran sudo -l and got the following:

```<code>User [user-name] may run the following commands on [computer-name]:
    (ALL) ALL
</code>```

None of that seemed to work either.

I also use IntelliJ as my Java IDE; I don't know if something changed there that I'm unaware of.

Any help is appreciated. I would really just like to change my java version and have it working properly on my machine, and up until recently (aside from using jenv) I would change my JAVA_HOME value to wherever I had a version of Java installed.

Edit: Worth noting that when I run java -version, I get the following:

```<code>java -version
openjdk version "17.0.4.1" 2022-08-12 LTS
OpenJDK Runtime Environment Corretto-17.0.4.9.1 (build 17.0.4.1+9-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.4.9.1 (build 17.0.4.1+9-LTS, mixed mode, sharing)
</code>```

I've also gone through various tutorials and other stackoverflow questions on how to set the JAVA_HOME environment variable, including:

https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/

How to set JAVA_HOME environment variable on Mac OS X 10.9?

https://www.youtube.com/watch?v=mENryUqoNzY

UPDATE: As per a suggestion in the comments below, I changed my export statement in ~/.zshrc to

```<code>export JAVA_HOME=$HOME/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home
</code>```

When I run source ~/.zshrc after that change, the console doesn't print permission denied, but when I run echo $JAVA_HOME I still get a blank line (followed by the jenv complaint).

Body:
I am trying to fix Java for projects I am working on on my local computer. I had jenv installed to switch between versions more easily, but at some point over the last couple of days I must have done something and messed up my JAVA_HOME environment variable and now I can't seem to fix it.

I use zsh, and I am on a Mac running MacOS Monterey 12.2. I first tried uninstalling jenv (brew uninstall jenv - just wasn't really using it and seemed to be making things more confusing to solve this issue). Even though I did that and took jenv out of my $PATH variable, whenever I run almost any command in the terminal the statement "jenv:11: command not found: jenv" prints. I'm not sure if that is a lesser issue, but something that probably needs to be solved.

My bigger issue is fixing Java on my machine. Up until a couple days ago this was not an issue, but now if I try to set JAVA_HOME in my .zshrc file like this

export JAVA_HOME=$(/Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home)

and run source ~/.zshrc I get the message:

/Users/[user-name]/.zshrc:119: permission denied: /Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home

This happens no matter which Java version I try to set JAVA_HOME to. My Java installation directories and versions are as follows:

# dir - /Library/Java/JavaVirtualMachines
drwxr-xr-x  3 root  wheel   96 Apr 20  2021 adoptopenjdk-8.jdk
drwxr-xr-x  3 root  wheel   96 Oct 19 08:54 temurin-11.jdk

# dir - /Users/[user-name]/Library/Java/JavaVirtualMachines
drwxr-xr-x  3 [user-name]  staff   96 Dec 10 11:36 corretto-11.0.17
drwxr-xr-x  3 [user-name]  staff   96 Sep 30 09:56 corretto-17.0.4.1

Running /usr/libexec/java_home -V prints the following:

Matching Java Virtual Machines (4):
    17.0.4 (x86_64) "Amazon.com Inc." - "Amazon Corretto 17" /Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-17.0.4.1/Contents/Home
    11.0.17 (x86_64) "Amazon.com Inc." - "Amazon Corretto 11" /Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home
    11.0.17 (x86_64) "Eclipse Adoptium" - "OpenJDK 11.0.17" /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
    1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
/Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-17.0.4.1/Contents/Home

If I run echo $JAVA_HOME, a blank line prints followed by jenv:11: command not found: jenv.

I tried to run unset JAVA_HOME, followed by either:

export JAVA_HOME=/Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home

or

export JAVA_HOME=$(/Users/[user-name]/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home)

and don't get a permission denied error, only the jenv:11: command not found: jenv complaint. But after, if I run echo $JAVA_HOME, I still get a blank line followed by the jenv complaint.

It seems like no matter what I do, something keeps preventing me from setting JAVA_HOME.

Out of desperation, I ran mod 777 ~/.zshrc, and also checked System Preferences -> Security and Privacy -> Full Disk Access and made sure that iTerm was checked in that list, and to check my user permissions I ran sudo -l and got the following:

User [user-name] may run the following commands on [computer-name]:
    (ALL) ALL

None of that seemed to work either.

I also use IntelliJ as my Java IDE; I don't know if something changed there that I'm unaware of.

Any help is appreciated. I would really just like to change my java version and have it working properly on my machine, and up until recently (aside from using jenv) I would change my JAVA_HOME value to wherever I had a version of Java installed.

Edit: Worth noting that when I run java -version, I get the following:

java -version
openjdk version "17.0.4.1" 2022-08-12 LTS
OpenJDK Runtime Environment Corretto-17.0.4.9.1 (build 17.0.4.1+9-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.4.9.1 (build 17.0.4.1+9-LTS, mixed mode, sharing)

I've also gone through various tutorials and other stackoverflow questions on how to set the JAVA_HOME environment variable, including:

https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/

How to set JAVA_HOME environment variable on Mac OS X 10.9?

https://www.youtube.com/watch?v=mENryUqoNzY

UPDATE: As per a suggestion in the comments below, I changed my export statement in ~/.zshrc to

export JAVA_HOME=$HOME/Library/Java/JavaVirtualMachines/corretto-11.0.17/Contents/Home

When I run source ~/.zshrc after that change, the console doesn't print permission denied, but when I run echo $JAVA_HOME I still get a blank line (followed by the jenv complaint).


来源: stackexchange

问:
Library tsc print image
hello I send you a greeting.

I have a question how to print an image in python dll tsc example?
have tried to use downloadbmp() without success

```<code>    tsclibrary = ctypes.WinDLL(".//libs//TSCLIB.dll")
    tsclibrary.openportW("TSC_TE200")

    tsclibrary.sendcommandW("SIZE 50 mm, 25 mm")
    tsclibrary.sendcommandW("GAP 2 mm, 0 mm")
    tsclibrary.sendcommandW("DIRECTION 1")
    tsclibrary.sendcommandW("CLS")
    tsclibrary.downloadbmp('QR.BMP','QR.BMP')//not function ???
    tsclibrary.sendcommandW("PUTBMP 50,25,\"QR.BMP\"") //not function ???
    tsclibrary.printlabelW("1", "1")
    tsclibrary.closeport()
</code>```

help pleace!!!!!!!

I have tried to use downloadbmp() without success

```<code>tsclibrary.downloadbmp('QR.BMP','QR.BMP')//not function ???
    tsclibrary.sendcommandW("PUTBMP 50,25,\"QR.BMP\"") //not function ???
</code>```

ContentLicense: CC BY-SA 4.0

Title: Library tsc print image

Body:
hello I send you a greeting.

I have a question how to print an image in python dll tsc example?
have tried to use downloadbmp() without success

    tsclibrary = ctypes.WinDLL(".//libs//TSCLIB.dll")
    tsclibrary.openportW("TSC_TE200")

    tsclibrary.sendcommandW("SIZE 50 mm, 25 mm")
    tsclibrary.sendcommandW("GAP 2 mm, 0 mm")
    tsclibrary.sendcommandW("DIRECTION 1")
    tsclibrary.sendcommandW("CLS")
    tsclibrary.downloadbmp('QR.BMP','QR.BMP')//not function ???
    tsclibrary.sendcommandW("PUTBMP 50,25,\"QR.BMP\"") //not function ???
    tsclibrary.printlabelW("1", "1")
    tsclibrary.closeport()

help pleace!!!!!!!

I have tried to use downloadbmp() without success

tsclibrary.downloadbmp('QR.BMP','QR.BMP')//not function ???
    tsclibrary.sendcommandW("PUTBMP 50,25,\"QR.BMP\"") //not function ???


问:
Pytorch model gradients no updating with some custom code
I have an object detection task that requires to recognise multiple objects from an image. The idea is to define a simple network from scratch (i.e. without using ready implementations of YoLo or similar algorithms). Our approach was to define an architecture that was able to detect a single bounding box, and then to execute different independent copies of the same model on the data in parallel. Our architecture was defined as the following:

class MultiObjectNet(nn.Module):
    def __init__(self, image_width, image_height, num_classes=13, num_boxes=5, device=torch.device('mps')):
        super(MultiObjectNet, self).__init__()
        self.device = device
        self.pool = nn.MaxPool2d(kernel_size=2, stride=2)
        self.initial_conv1 = nn.Conv2d(in_channels=3, out_channels=64, kernel_size=4, stride=2, padding=1, device=self.device)
        self.initial_conv2 = nn.Conv2d(in_channels=64, out_channels=128, kernel_size=4, stride=2, padding=1, device=self.device)
        self.initial_conv3 = nn.Conv2d(in_channels=128, out_channels=256, kernel_size=2, stride=2, device=self.device)

        self.no_pools1 = nn.Conv2d(in_channels=256, out_channels=512, kernel_size=3, stride=2, device=self.device)
        self.no_pools2 = nn.Conv2d(in_channels=512, out_channels=1024, kernel_size=3, stride=3, device=self.device)

        self.fc1 = nn.Linear(in_features=1024, out_features=512, device=self.device)
        self.fc2 = nn.Linear(in_features=512, out_features=256, device=self.device)
        self.fc3 = nn.Linear(in_features=256, out_features=128, device=self.device)
        self.fc4 = nn.Linear(in_features=128, out_features=64, device=self.device)

        self.pc_layer = nn.Linear(in_features=64, out_features=1, device=self.device)
        self.box_layer = nn.Linear(in_features=64, out_features=4, device=self.device)
        self.category_layer = nn.Linear(in_features=64, out_features=num_classes, device=self.device)

        self.sigmoid = nn.Sigmoid()

        self.num_classes = num_classes
        self.num_boxes = num_boxes

    def __device__(self):
        return self.device

    def forward(self, x):

        x = self.initial_conv1(x)
        x = F.relu(x)
        x = self.pool(x)
        x = self.initial_conv2(x)
        x = F.relu(x)
        x = self.pool(x)
        x = self.initial_conv3(x)
        x = F.relu(x)
        x = self.pool(x)

        x = self.no_pools1(x)
        x = F.relu(x)
        x = self.no_pools2(x)
        x = F.relu(x)

        x = torch.transpose(x,1,3)[::,0][:,0]
        x = self.fc1(x)
        x = F.relu(x)
        x = self.fc2(x)
        x = F.relu(x)
        x = self.fc3(x)
        x = F.relu(x)
        x = self.fc4(x)
        x = F.relu(x)

        return self.sigmoid(self.pc_layer(x)), self.box_layer(x), self.category_layer(x)
```
<p>The network outputs a triple $(P_C, [x_{min}, y_{min}, x_{max}, y_{max}], CAT)$, where the inner list contains the coordinates of the bounding box and $CAT$ is a probability distribution over the classes of the dataset.
The training and loss calculation were computed as following:</p>
<pre class="lang-py prettyprint-override"><code>nets = [ MultiObjectNet(resizing_width, resizing_height, device=torch.device('mps')) for _ in range(max_boxes) ]

loss_df = pd.DataFrame(index=list(range(100)), columns=["loss"])

learning_rate = 1e-02
optims = [ torch.optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9) for net in nets ]

bce_loss = torch.nn.BCELoss()
mse_loss = torch.nn.MSELoss()
xent_loss = torch.nn.CrossEntropyLoss()

for epoch in range(5):
    running_loss = 0.0
    for batch_number, batch in tqdm(enumerate(train_dataloader)) :
        inputs, labels = batch
        batch_size = len(inputs)
        for i, (optim, net, label) in enumerate(zip(optims, nets, labels)) :
          pred_pc, pred_box, pred_category = net(inputs)
          y_pc, y_box, y_category = label[0].reshape(batch_size, 1), label[1].reshape(batch_size, 4), label[2].reshape(batch_size, num_classes)
          optim.zero_grad()
          confidence_loss = bce_loss(pred_pc, y_pc)
          box_loss = mse_loss(pred_box, y_box))
          category_loss = xent_loss(pred_category, y_category)
          loss = confidence_loss + box_loss + category_loss
          loss.backward()
          optim.step()
</code>```

My model fails to generalize the problem and fixates on a single output, no matter the input given to the network (always outputs very similar confidence probabilities, boxes and categories distributions). By looking into the first layer parameters, I can see that the gradient is not None, thus I suppose that there is some kind of learning, but I can't understand what is happening.

Body:
I have an object detection task that requires to recognise multiple objects from an image. The idea is to define a simple network from scratch (i.e. without using ready implementations of YoLo or similar algorithms). Our approach was to define an architecture that was able to detect a single bounding box, and then to execute different independent copies of the same model on the data in parallel. Our architecture was defined as the following:

class MultiObjectNet(nn.Module):
    def __init__(self, image_width, image_height, num_classes=13, num_boxes=5, device=torch.device('mps')):
        super(MultiObjectNet, self).__init__()
        self.device = device
        self.pool = nn.MaxPool2d(kernel_size=2, stride=2)
        self.initial_conv1 = nn.Conv2d(in_channels=3, out_channels=64, kernel_size=4, stride=2, padding=1, device=self.device)
        self.initial_conv2 = nn.Conv2d(in_channels=64, out_channels=128, kernel_size=4, stride=2, padding=1, device=self.device)
        self.initial_conv3 = nn.Conv2d(in_channels=128, out_channels=256, kernel_size=2, stride=2, device=self.device)

        self.no_pools1 = nn.Conv2d(in_channels=256, out_channels=512, kernel_size=3, stride=2, device=self.device)
        self.no_pools2 = nn.Conv2d(in_channels=512, out_channels=1024, kernel_size=3, stride=3, device=self.device)

        self.fc1 = nn.Linear(in_features=1024, out_features=512, device=self.device)
        self.fc2 = nn.Linear(in_features=512, out_features=256, device=self.device)
        self.fc3 = nn.Linear(in_features=256, out_features=128, device=self.device)
        self.fc4 = nn.Linear(in_features=128, out_features=64, device=self.device)

        self.pc_layer = nn.Linear(in_features=64, out_features=1, device=self.device)
        self.box_layer = nn.Linear(in_features=64, out_features=4, device=self.device)
        self.category_layer = nn.Linear(in_features=64, out_features=num_classes, device=self.device)

        self.sigmoid = nn.Sigmoid()

        self.num_classes = num_classes
        self.num_boxes = num_boxes

    def __device__(self):
        return self.device

    def forward(self, x):

        x = self.initial_conv1(x)
        x = F.relu(x)
        x = self.pool(x)
        x = self.initial_conv2(x)
        x = F.relu(x)
        x = self.pool(x)
        x = self.initial_conv3(x)
        x = F.relu(x)
        x = self.pool(x)

        x = self.no_pools1(x)
        x = F.relu(x)
        x = self.no_pools2(x)
        x = F.relu(x)

        x = torch.transpose(x,1,3)[::,0][:,0]
        x = self.fc1(x)
        x = F.relu(x)
        x = self.fc2(x)
        x = F.relu(x)
        x = self.fc3(x)
        x = F.relu(x)
        x = self.fc4(x)
        x = F.relu(x)

        return self.sigmoid(self.pc_layer(x)), self.box_layer(x), self.category_layer(x)

The network outputs a triple $(P_C, [x_{min}, y_{min}, x_{max}, y_{max}], CAT)$, where the inner list contains the coordinates of the bounding box and $CAT$ is a probability distribution over the classes of the dataset.
The training and loss calculation were computed as following:

nets = [ MultiObjectNet(resizing_width, resizing_height, device=torch.device('mps')) for _ in range(max_boxes) ]

loss_df = pd.DataFrame(index=list(range(100)), columns=["loss"])

learning_rate = 1e-02
optims = [ torch.optim.SGD(net.parameters(), lr=learning_rate, momentum=0.9) for net in nets ]

bce_loss = torch.nn.BCELoss()
mse_loss = torch.nn.MSELoss()
xent_loss = torch.nn.CrossEntropyLoss()

for epoch in range(5):
    running_loss = 0.0
    for batch_number, batch in tqdm(enumerate(train_dataloader)) :
        inputs, labels = batch
        batch_size = len(inputs)
        for i, (optim, net, label) in enumerate(zip(optims, nets, labels)) :
          pred_pc, pred_box, pred_category = net(inputs)
          y_pc, y_box, y_category = label[0].reshape(batch_size, 1), label[1].reshape(batch_size, 4), label[2].reshape(batch_size, num_classes)
          optim.zero_grad()
          confidence_loss = bce_loss(pred_pc, y_pc)
          box_loss = mse_loss(pred_box, y_box))
          category_loss = xent_loss(pred_category, y_category)
          loss = confidence_loss + box_loss + category_loss
          loss.backward()
          optim.step()

My model fails to generalize the problem and fixates on a single output, no matter the input given to the network (always outputs very similar confidence probabilities, boxes and categories distributions). By looking into the first layer parameters, I can see that the gradient is not None, thus I suppose that there is some kind of learning, but I can't understand what is happening.


问:
Make nn.Transformer work for Text Generation
I am trying to make a Transformer work for paraphrase generation but the generations are not useful (the same everytime, full of BOS tokens or "?" tokens).
I followed this tutorial for reference. My implementation is embedded into a framework which requires an Encoder and a Decoder:

The encoder is like this:

```<code>class TransformerEncoder(nn.Module):
    def __init__(
        self,
        vocab_size,
        pad_token_id=None,
        embedding_size=256,
        num_heads=8,
        num_layers=3,
        ffnn_size=512,
        dropout=0.1,
    ):
        super(TransformerEncoder, self).__init__()
        self.vocab_size = vocab_size
        self.pad_token_id = pad_token_id

        self.embedding_size = embedding_size
        self.num_heads = num_heads
        self.num_layers = num_layers
        self.ffnn_size = ffnn_size

        self.embed_tokens = TokenEmbedding(vocab_size, embedding_size)
        self.embed_positions = PositionalEmbedding(embedding_size, dropout=dropout)

        encoder_layer = nn.TransformerEncoderLayer(
            embedding_size,
            num_heads,
            ffnn_size,
            dropout,
        )
        encoder_norm = nn.LayerNorm(embedding_size)
        self.encoder = nn.TransformerEncoder(encoder_layer, num_layers, encoder_norm)

    def forward(
        self,
        input_ids,
    ):

        # seq_len = input_ids.shape[1]
        # device = next(self.parameters()).device

        embedded_tokens = self.embed_positions(self.embed_tokens(input_ids))
        # B x T x C -> T x B x C
        embedded_tokens = embedded_tokens.transpose(0, 1)

        memory = self.encoder(embedded_tokens)

        return (memory,)
</code>```

The decoder is like this:

```<code>class TransformerDecoder(nn.Module):
    def __init__(
        self,
        vocab_size,
        pad_token_id=None,
        embedding_size=256,
        num_heads=8,
        num_layers=3,
        ffnn_size=512,
        dropout=0.1,
    ):

        super(TransformerDecoder, self).__init__()
        self.vocab_size = vocab_size
        self.pad_token_id = pad_token_id

        self.embedding_size = embedding_size
        self.num_heads = num_heads
        self.num_layers = num_layers
        self.ffnn_size = ffnn_size

        self.dropout_module = nn.Dropout(p=dropout)

        self.embed_tokens = TokenEmbedding(vocab_size, embedding_size)
        self.embed_positions = PositionalEmbedding(embedding_size, dropout=dropout)

        decoder_layer = nn.TransformerDecoderLayer(
            embedding_size, num_heads, ffnn_size, dropout
        )
        decoder_norm = nn.LayerNorm(embedding_size)
        self.decoder = nn.TransformerDecoder(decoder_layer, num_layers, decoder_norm)
        self.fc_out = nn.Linear(embedding_size, vocab_size)

    def forward(
        self,
        input_ids,
        encoder_out,
    ):
        seq_len = input_ids.shape[1]

        device = next(self.parameters()).device
        mask = generate_square_subsequent_mask(seq_len).to(device)

        embedded_tokens = self.embed_positions(self.embed_tokens(input_ids))

        # B x T x C -> T x B x C
        embedded_tokens = embedded_tokens.transpose(0, 1)

        output = self.decoder(embedded_tokens, encoder_out[0], tgt_mask=mask)

        # T x B x C -> B x T x C
        output = output.transpose(1, 0)

        return (self.fc_out(output),)
</code>```

TokenEmbedding and PositionalEmbedding are as in the tutorial.
The main model just invokes encoder and decoder like:

```<code>        encoder_outputs = self.encoder(input_ids=input_ids, **kwargs)

        decoder_outputs = self.decoder(
            input_ids=decoder_input_ids,
            encoder_out=encoder_outputs,
            **kwargs,
        )
</code>```

The labels are shifted one token to the right to be fed to the decoder using:

```<code>def shift_tokens_right(self, input_ids: torch.Tensor, decoder_start_token_id: int):
   shifted_input_ids = input_ids.new_zeros(input_ids.shape)
   shifted_input_ids[:, 1:] = input_ids[:, :-1].clone()
   shifted_input_ids[:, 0] = decoder_start_token_id
   return shifted_input_ids
</code>```

The loss is calculated as:

```<code>loss_fct = nn.CrossEntropyLoss(ignore_index=self.pad_token_id)
loss = loss_fct(logits.reshape(-1, logits.shape[-1]), targets.reshape(-1))
</code>```

The loss is going down, but the generations are real bad. Following is an example of the generations:
Source: < s > Can I jailbreak iOS 10 ? < /s > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad >
Preds: < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s >
Target: < s > Can you jailbreak iOS 10 ? < /s > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad >

As you can see, the predictions in this case are only BOS tokens. The output of the decoder on each decoder step is always almost the same for every iteration. The model does not seem to be learning. I have tried learning rates from 0.1 to 1e-4. For a brief moment at the second or third epoch, there were produced intelligible sentences, but quickly after that the generations reverted back to just BOS or PAD tokens.

Do you have an intuition on what might be wrong? Sorry for the question not being self-contained. Thanks in advance for any help you can provide.

Body:
I am trying to make a Transformer work for paraphrase generation but the generations are not useful (the same everytime, full of BOS tokens or "?" tokens).
I followed this tutorial for reference. My implementation is embedded into a framework which requires an Encoder and a Decoder:

The encoder is like this:

class TransformerEncoder(nn.Module):
    def __init__(
        self,
        vocab_size,
        pad_token_id=None,
        embedding_size=256,
        num_heads=8,
        num_layers=3,
        ffnn_size=512,
        dropout=0.1,
    ):
        super(TransformerEncoder, self).__init__()
        self.vocab_size = vocab_size
        self.pad_token_id = pad_token_id

        self.embedding_size = embedding_size
        self.num_heads = num_heads
        self.num_layers = num_layers
        self.ffnn_size = ffnn_size

        self.embed_tokens = TokenEmbedding(vocab_size, embedding_size)
        self.embed_positions = PositionalEmbedding(embedding_size, dropout=dropout)

        encoder_layer = nn.TransformerEncoderLayer(
            embedding_size,
            num_heads,
            ffnn_size,
            dropout,
        )
        encoder_norm = nn.LayerNorm(embedding_size)
        self.encoder = nn.TransformerEncoder(encoder_layer, num_layers, encoder_norm)

    def forward(
        self,
        input_ids,
    ):

        # seq_len = input_ids.shape[1]
        # device = next(self.parameters()).device

        embedded_tokens = self.embed_positions(self.embed_tokens(input_ids))
        # B x T x C -> T x B x C
        embedded_tokens = embedded_tokens.transpose(0, 1)

        memory = self.encoder(embedded_tokens)

        return (memory,)

The decoder is like this:

class TransformerDecoder(nn.Module):
    def __init__(
        self,
        vocab_size,
        pad_token_id=None,
        embedding_size=256,
        num_heads=8,
        num_layers=3,
        ffnn_size=512,
        dropout=0.1,
    ):

        super(TransformerDecoder, self).__init__()
        self.vocab_size = vocab_size
        self.pad_token_id = pad_token_id

        self.embedding_size = embedding_size
        self.num_heads = num_heads
        self.num_layers = num_layers
        self.ffnn_size = ffnn_size

        self.dropout_module = nn.Dropout(p=dropout)

        self.embed_tokens = TokenEmbedding(vocab_size, embedding_size)
        self.embed_positions = PositionalEmbedding(embedding_size, dropout=dropout)

        decoder_layer = nn.TransformerDecoderLayer(
            embedding_size, num_heads, ffnn_size, dropout
        )
        decoder_norm = nn.LayerNorm(embedding_size)
        self.decoder = nn.TransformerDecoder(decoder_layer, num_layers, decoder_norm)
        self.fc_out = nn.Linear(embedding_size, vocab_size)

    def forward(
        self,
        input_ids,
        encoder_out,
    ):
        seq_len = input_ids.shape[1]

        device = next(self.parameters()).device
        mask = generate_square_subsequent_mask(seq_len).to(device)

        embedded_tokens = self.embed_positions(self.embed_tokens(input_ids))

        # B x T x C -> T x B x C
        embedded_tokens = embedded_tokens.transpose(0, 1)

        output = self.decoder(embedded_tokens, encoder_out[0], tgt_mask=mask)

        # T x B x C -> B x T x C
        output = output.transpose(1, 0)

        return (self.fc_out(output),)

TokenEmbedding and PositionalEmbedding are as in the tutorial.
The main model just invokes encoder and decoder like:

        encoder_outputs = self.encoder(input_ids=input_ids, **kwargs)

        decoder_outputs = self.decoder(
            input_ids=decoder_input_ids,
            encoder_out=encoder_outputs,
            **kwargs,
        )

The labels are shifted one token to the right to be fed to the decoder using:

def shift_tokens_right(self, input_ids: torch.Tensor, decoder_start_token_id: int):
   shifted_input_ids = input_ids.new_zeros(input_ids.shape)
   shifted_input_ids[:, 1:] = input_ids[:, :-1].clone()
   shifted_input_ids[:, 0] = decoder_start_token_id
   return shifted_input_ids

The loss is calculated as:

loss_fct = nn.CrossEntropyLoss(ignore_index=self.pad_token_id)
loss = loss_fct(logits.reshape(-1, logits.shape[-1]), targets.reshape(-1))

The loss is going down, but the generations are real bad. Following is an example of the generations:
Source: < s > Can I jailbreak iOS 10 ? < /s > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad >
Preds: < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s > < s >
Target: < s > Can you jailbreak iOS 10 ? < /s > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad > < pad >

As you can see, the predictions in this case are only BOS tokens. The output of the decoder on each decoder step is always almost the same for every iteration. The model does not seem to be learning. I have tried learning rates from 0.1 to 1e-4. For a brief moment at the second or third epoch, there were produced intelligible sentences, but quickly after that the generations reverted back to just BOS or PAD tokens.

Do you have an intuition on what might be wrong? Sorry for the question not being self-contained. Thanks in advance for any help you can provide.


问:
Spring UnsatisfiedDependencyException 2
I see other people have posted similar questions regarding the same project from YouTube but I have a slightly different problem. My problem is that I keep getting:
Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentService' defined in file

Hello, I am trying to follow this tutorial on YouTube called Spring Boot Tutorial | Full Course [2022] [NEW] located at https://www.youtube.com/watch?v=9SGDpanrc8U&t=3141s

Everything is going along fine until I get to StudentService and StudentRepository

The error I keep getting is Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentService'

Side Note: Should I troubleshoot from the top or bottom of the stack trace?

.   ____          _            __ _ _
/\ / ' __ _ () __  __ _ \ \ \

( ( )__ | '_ | '| | ' / ` | \ \ \

\/  __)| |)| | | | | || (| |  ) ) ) )
'  || .__|| ||| |_, | / / / /
=========||==============|/=////
:: Spring Boot ::       (v3.0.1-SNAPSHOT)

2022-12-12T08:20:56.844-08:00  INFO 13088 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication using Java 17.0.5 with PID 13088 (C:\Users\19163\Desktop\demo\target\classes started by 19163 in C:\Users\19163\Desktop\demo)
2022-12-12T08:20:56.854-08:00  INFO 13088 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2022-12-12T08:20:57.617-08:00  INFO 13088 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-12-12T08:20:57.697-08:00  INFO 13088 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 60 ms. Found 1 JPA repository interfaces.
2022-12-12T08:20:58.272-08:00  INFO 13088 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-12-12T08:20:58.283-08:00  INFO 13088 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-12-12T08:20:58.284-08:00  INFO 13088 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.4]
2022-12-12T08:20:58.396-08:00  INFO 13088 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-12-12T08:20:58.397-08:00  INFO 13088 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1447 ms
2022-12-12T08:20:58.593-08:00  INFO 13088 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-12-12T08:20:58.668-08:00  INFO 13088 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.1.5.Final
2022-12-12T08:20:58.897-08:00  WARN 13088 --- [           main] org.hibernate.orm.deprecation            : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
2022-12-12T08:20:59.042-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2022-12-12T08:21:00.466-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@2edb2f8b
2022-12-12T08:21:00.468-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2022-12-12T08:21:00.599-08:00  INFO 13088 --- [           main] SQL dialect                              : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2022-12-12T08:21:01.117-08:00  INFO 13088 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-12-12T08:21:01.131-08:00  INFO 13088 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-12-12T08:21:01.270-08:00  WARN 13088 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentController' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentService' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentRepository' defined in com.example.demo.StudentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.demo.Student
2022-12-12T08:21:01.271-08:00  INFO 13088 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-12-12T08:21:01.273-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2022-12-12T08:21:01.441-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2022-12-12T08:21:01.443-08:00  INFO 13088 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-12-12T08:21:01.457-08:00  INFO 13088 --- [           main] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2022-12-12T08:21:01.477-08:00 ERROR 13088 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentController' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentService' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentRepository' defined in com.example.demo.StudentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.demo.Student
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[spring-context-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at com.example.demo.DemoApplication.main(DemoApplication.java:12) ~[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentService' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentRepository' defined in com.example.demo.StudentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.demo.Student
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentRepository' defined in com.example.demo.StudentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.demo.Student
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1751) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
... 33 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.example.demo.Student
at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.managedType(JpaMetamodelImpl.java:181) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:496) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:99) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.(JpaMetamodelEntityInformation.java:77) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:69) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:246) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:211) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:194) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:317) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:279) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:229) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.util.Lazy.get(Lazy.java:113) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:285) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
... 44 common frames omitted

Process finished with exit code 1

Things I have already tried:

I tried arranging the files and packages as they are in the video so EntityScan is not needed, no
success

I tried putting all java files including the main class in the same package with no success

I tried updating the Maven Project but intellij ultimate will not update the maven repository

I tried putting DemoApplication in the main package called "com.example.demo" and all student
related files in a subpackage called "com.example.demo.student" to use with EntityScan with no
success
Always get the same exact error

I am on a Windows 10 laptop, using Spring Boot 3.0, and IntelliJ Ultimate
Here is my pom.xml file

4.0.0

org.springframework.boot
spring-boot-starter-parent
3.0.1-SNAPSHOT

com.example
demo
0.0.1-SNAPSHOT
demo
Demo project for Spring Boot

<java.version>17</java.version>

org.springframework.boot
spring-boot-starter-data-jpa

org.springframework.boot
spring-boot-starter-web

```<code>    <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.eclipse.persistence/eclipselink -->
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.5.0</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>
</code>```

Here is my current project structure

Any help will be appreciated

Title: Spring UnsatisfiedDependencyException 2

Body:
I see other people have posted similar questions regarding the same project from YouTube but I have a slightly different problem. My problem is that I keep getting:
Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentService' defined in file

Hello, I am trying to follow this tutorial on YouTube called Spring Boot Tutorial | Full Course [2022] [NEW] located at https://www.youtube.com/watch?v=9SGDpanrc8U&t=3141s

Everything is going along fine until I get to StudentService and StudentRepository

The error I keep getting is Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentService'

Side Note: Should I troubleshoot from the top or bottom of the stack trace?

.   ____          _            __ _ _
/\ / ' __ _ () __  __ _ \ \ \

( ( )__ | '_ | '| | ' / ` | \ \ \

\/  __)| |)| | | | | || (| |  ) ) ) )
'  || .__|| ||| |_, | / / / /
=========||==============|/=////
:: Spring Boot ::       (v3.0.1-SNAPSHOT)

2022-12-12T08:20:56.844-08:00  INFO 13088 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication using Java 17.0.5 with PID 13088 (C:\Users\19163\Desktop\demo\target\classes started by 19163 in C:\Users\19163\Desktop\demo)
2022-12-12T08:20:56.854-08:00  INFO 13088 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2022-12-12T08:20:57.617-08:00  INFO 13088 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-12-12T08:20:57.697-08:00  INFO 13088 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 60 ms. Found 1 JPA repository interfaces.
2022-12-12T08:20:58.272-08:00  INFO 13088 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-12-12T08:20:58.283-08:00  INFO 13088 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-12-12T08:20:58.284-08:00  INFO 13088 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.4]
2022-12-12T08:20:58.396-08:00  INFO 13088 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-12-12T08:20:58.397-08:00  INFO 13088 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1447 ms
2022-12-12T08:20:58.593-08:00  INFO 13088 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2022-12-12T08:20:58.668-08:00  INFO 13088 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.1.5.Final
2022-12-12T08:20:58.897-08:00  WARN 13088 --- [           main] org.hibernate.orm.deprecation            : HHH90000021: Encountered deprecated setting [javax.persistence.sharedCache.mode], use [jakarta.persistence.sharedCache.mode] instead
2022-12-12T08:20:59.042-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2022-12-12T08:21:00.466-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@2edb2f8b
2022-12-12T08:21:00.468-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2022-12-12T08:21:00.599-08:00  INFO 13088 --- [           main] SQL dialect                              : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2022-12-12T08:21:01.117-08:00  INFO 13088 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2022-12-12T08:21:01.131-08:00  INFO 13088 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2022-12-12T08:21:01.270-08:00  WARN 13088 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentController' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentService' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentRepository' defined in com.example.demo.StudentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.demo.Student
2022-12-12T08:21:01.271-08:00  INFO 13088 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2022-12-12T08:21:01.273-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2022-12-12T08:21:01.441-08:00  INFO 13088 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2022-12-12T08:21:01.443-08:00  INFO 13088 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2022-12-12T08:21:01.457-08:00  INFO 13088 --- [           main] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2022-12-12T08:21:01.477-08:00 ERROR 13088 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentController' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentService' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentRepository' defined in com.example.demo.StudentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.demo.Student
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[spring-context-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.1-20221212.130302-27.jar:3.0.1-SNAPSHOT]
at com.example.demo.DemoApplication.main(DemoApplication.java:12) ~[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentService' defined in file [C:\Users\19163\Desktop\demo\target\classes\com\example\demo\StudentService.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'studentRepository' defined in com.example.demo.StudentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.demo.Student
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentRepository' defined in com.example.demo.StudentRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.demo.Student
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1751) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
... 33 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.example.demo.Student
at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.managedType(JpaMetamodelImpl.java:181) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:496) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:99) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.(JpaMetamodelEntityInformation.java:77) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:69) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:246) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:211) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:194) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:317) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:279) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:229) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.util.Lazy.get(Lazy.java:113) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:285) ~[spring-data-commons-3.0.0.jar:3.0.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132) ~[spring-data-jpa-3.0.0.jar:3.0.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.3-20221212.155846-51.jar:6.0.3-SNAPSHOT]
... 44 common frames omitted

Process finished with exit code 1

Things I have already tried:

I tried arranging the files and packages as they are in the video so EntityScan is not needed, no
success

I tried putting all java files including the main class in the same package with no success

I tried updating the Maven Project but intellij ultimate will not update the maven repository

I tried putting DemoApplication in the main package called "com.example.demo" and all student
related files in a subpackage called "com.example.demo.student" to use with EntityScan with no
success
Always get the same exact error

I am on a Windows 10 laptop, using Spring Boot 3.0, and IntelliJ Ultimate
Here is my pom.xml file

4.0.0

org.springframework.boot
spring-boot-starter-parent
3.0.1-SNAPSHOT

com.example
demo
0.0.1-SNAPSHOT
demo
Demo project for Spring Boot

<java.version>17</java.version>

org.springframework.boot
spring-boot-starter-data-jpa

org.springframework.boot
spring-boot-starter-web

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>

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

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.5.0</version>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
<repositories>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
    <pluginRepository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <releases>
            <enabled>false</enabled>
        </releases>
    </pluginRepository>
</pluginRepositories>

Here is my current project structure

Any help will be appreciated


问:
EF Core 6 changes boolean false value to default true from Fluent API on save changes
This is my code

```<code>var data = new Data();
data.ID = Guid.NewGuid();
data.Active = false;

_context.Data.Add(data);
_context.SaveChanges();

</code>```

If I put breakpoint on _context.SaveChanges(), and put mouse over data.Active it's false, but next line after saving it becomes true.

I got this in OnModelCreating, but how it cannot be explicitly changed to non default one.

```<code>modelBuilder.Entity<Data>()
            .Property(t => t.Active)
            .HasDefaultValue(true);
</code>```

Body:
This is my code

var data = new Data();
data.ID = Guid.NewGuid();
data.Active = false;

_context.Data.Add(data);
_context.SaveChanges();

If I put breakpoint on _context.SaveChanges(), and put mouse over data.Active it's false, but next line after saving it becomes true.

I got this in OnModelCreating, but how it cannot be explicitly changed to non default one.

modelBuilder.Entity<Data>()
            .Property(t => t.Active)
            .HasDefaultValue(true);


问:
Best practice for implementing and then retrieving user group permissions/settings in Blazor WebAssembly
I am going to be creating a web application using Blazor WebAssembly (hosted by an ASP.NET Core backend). This web application will be used by schools, each of which will have their own individual group of users. Users can only belong to one school. Within this application there will be settings that apply at school level and at user role level. I will need to be able to access these settings client side as well as server side.

For example, at school level I will need a boolean setting that grants access to a specific section of the UI. I will need to be able to check that setting for any given user to see if the school they belong to has access to that UI or not.

What is the best approach for this? I will be using ASP.NET Identity, but that doesn't come pre-shipped with anything like User Groups. How can I easily and securely get the permissions set at school level so I can display the correct UI to a logged in user?


问:
How can I connect the same ListView-ItemBuilder with different lists?
Im trying to programm a grade point average-app, but I dont know how I can make a single grade point for every subject in my subject list. So when i add a grade to a single subject it is added to every subject.

Here are some parts of my code:

```<code>List<String> subjects = [
  'Mathematik',
  'Deutsch',
  'Englisch',
  'Geschichte',
  'Geographie',
  'WTH',
  'GK',
  'Religion',
  'Physik',
  'Chemie',
  'Informatik',
  'Sport',
  'Kunst',
  'Spanisch/Russisch',
];
...
      ListView.builder(
          itemCount: subjects.length,
          itemBuilder: (context, i) {
            return singleSubject(
              subjects[i],
              () => deleteItem(i),
            );
          },
      )

Different file:

List <int> gradeObjects = [];

...

void gradePointAverage() {
        setState(() {
          avg = gradeObjects.fold(0, (avg, element) => avg + element/gradeObjects.length);
        });
      }
</code>```

On now I didnt now what to do so please HEEELP MEEEE

Body:
Im trying to programm a grade point average-app, but I dont know how I can make a single grade point for every subject in my subject list. So when i add a grade to a single subject it is added to every subject.

Here are some parts of my code:

List<String> subjects = [
  'Mathematik',
  'Deutsch',
  'Englisch',
  'Geschichte',
  'Geographie',
  'WTH',
  'GK',
  'Religion',
  'Physik',
  'Chemie',
  'Informatik',
  'Sport',
  'Kunst',
  'Spanisch/Russisch',
];
...
      ListView.builder(
          itemCount: subjects.length,
          itemBuilder: (context, i) {
            return singleSubject(
              subjects[i],
              () => deleteItem(i),
            );
          },
      )

Different file:

List <int> gradeObjects = [];

...

void gradePointAverage() {
        setState(() {
          avg = gradeObjects.fold(0, (avg, element) => avg + element/gradeObjects.length);
        });
      }

On now I didnt now what to do so please HEEELP MEEEE


问:
Qlik Sense Pagination with nextToken and currentToken
I am looking for help on how to get all records in Qlik Sense from a data source, which works with pagination (currentToken and nextToken).

So far everything I have tried always gives me only the first 100 records, which is basically the limitation of the tool I am trying to get data from.

This is how my script looks:

```<code>LIB CONNECT TO 'REST_CALL';

// Action required: Implement the logic to retrieve the total records from the REST source and assign to the 'total' local variable.
Let total = 0;

Let totalfetched = 0;
Let startAt = 0;
Let pageSize = 100;

for startAt = 0 to total step pageSize
RestConnectorMasterTable:
SQL SELECT
    "__KEY_root",
    (SELECT
        "limit",
        "totalCount",
        "nextToken",
        "currentToken",
        "__KEY_paging",
        "__FK_paging",
        (SELECT
            "__KEY__links",
            "__FK__links",
            (SELECT
                "href",
                "__FK_next"
            FROM "next" FK "__FK_next"),
            (SELECT
                "href" AS "href_u0",
                "__FK_self"
            FROM "self" FK "__FK_self")
        FROM "_links" PK "__KEY__links" FK "__FK__links")
    FROM "paging" PK "__KEY_paging" FK "__FK_paging"),
    (SELECT
        "id" AS "id_u0",
        "title",
        "code",
        "description",
        "start",
        "end",
        "closeAfter",
        "archiveAfter",
        "launchAfter",
        "timezone",
        "defaultLocale",
        "currency",
        "registrationSecurityLevel",
        "status",
        "eventStatus",
        "testMode",
        "created",
        "lastModified",
        "virtual",
        "format",
        "type" AS "type_u0",
        "capacity",
        "__KEY_data",
        "__FK_data",
        (SELECT
            "name",
            "__KEY_venues",
            "__FK_venues",
            (SELECT
                "city",
                "country",
                "countryCode",
                "latitude",
                "longitude",
                "address1",
                "region",
                "regionCode",
                "postalCode",
                "__FK_address"
            FROM "address" FK "__FK_address")
        FROM "venues" PK "__KEY_venues" FK "__FK_venues"),
        (SELECT
            "firstName",
            "lastName",
            "email",
            "prefix",
            "__FK_planners"
        FROM "planners" FK "__FK_planners"),
        (SELECT
            "id",
            "name" AS "name_u0",
            "type",
            "order",
            "__KEY_customFields",
            "__FK_customFields",
            (SELECT
                "@Value",
                "__FK_value"
            FROM "value" FK "__FK_value" ArrayValueAlias "@Value")
        FROM "customFields" PK "__KEY_customFields" FK "__FK_customFields"),
        (SELECT
            "name" AS "name_u1",
            "__FK_category"
        FROM "category" FK "__FK_category"),
        (SELECT
            "__KEY__links_u0",
            "__FK__links_u0",
            (SELECT
                "href" AS "href_u1",
                "__FK_invitation"
            FROM "invitation" FK "__FK_invitation"),
            (SELECT
                "href" AS "href_u2",
                "__FK_agenda"
            FROM "agenda" FK "__FK_agenda"),
            (SELECT
                "href" AS "href_u3",
                "__FK_summary"
            FROM "summary" FK "__FK_summary"),
            (SELECT
                "href" AS "href_u4",
                "__FK_registration"
            FROM "registration" FK "__FK_registration")
        FROM "_links" PK "__KEY__links_u0" FK "__FK__links_u0"),
        (SELECT
            "@Value" AS "@Value_u0",
            "__FK_languages"
        FROM "languages" FK "__FK_languages" ArrayValueAlias "@Value_u0")
    FROM "data" PK "__KEY_data" FK "__FK_data")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(
QUERY "startAt" "$(startAt)",
URL "https://api-platform.sample.com/sample/sample",
QUERY "filter" "sample.id eq '123456789'",
HTTPHEADER "Authorization" "Bearer $(vToken)"
);

NEXT startAt;

</code>```

I tried to define the 'total' variable as follows so I can loop through all the records for the specific sample.id used above(948):

LET total=peek('totalCount');
TRACE $(total);

But the result is that it just loads the first 100 records 10 times.

Currently these are the settings of my connection:

Key Generation Strategy - SequenceID
Pagination Type - Custom

I tried also the next token pagination type, but it was also getting only the first 100 records.

My guess is that I have to somehow implement the nextToken and currentToken in the WITH CONNECTION part of my script, problem is that I don't know how to do that and if it is indeed what needs to be done.

Thanks in advance!

Body:
I am looking for help on how to get all records in Qlik Sense from a data source, which works with pagination (currentToken and nextToken).

So far everything I have tried always gives me only the first 100 records, which is basically the limitation of the tool I am trying to get data from.

This is how my script looks:

LIB CONNECT TO 'REST_CALL';

// Action required: Implement the logic to retrieve the total records from the REST source and assign to the 'total' local variable.
Let total = 0;

Let totalfetched = 0;
Let startAt = 0;
Let pageSize = 100;

for startAt = 0 to total step pageSize
RestConnectorMasterTable:
SQL SELECT
    "__KEY_root",
    (SELECT
        "limit",
        "totalCount",
        "nextToken",
        "currentToken",
        "__KEY_paging",
        "__FK_paging",
        (SELECT
            "__KEY__links",
            "__FK__links",
            (SELECT
                "href",
                "__FK_next"
            FROM "next" FK "__FK_next"),
            (SELECT
                "href" AS "href_u0",
                "__FK_self"
            FROM "self" FK "__FK_self")
        FROM "_links" PK "__KEY__links" FK "__FK__links")
    FROM "paging" PK "__KEY_paging" FK "__FK_paging"),
    (SELECT
        "id" AS "id_u0",
        "title",
        "code",
        "description",
        "start",
        "end",
        "closeAfter",
        "archiveAfter",
        "launchAfter",
        "timezone",
        "defaultLocale",
        "currency",
        "registrationSecurityLevel",
        "status",
        "eventStatus",
        "testMode",
        "created",
        "lastModified",
        "virtual",
        "format",
        "type" AS "type_u0",
        "capacity",
        "__KEY_data",
        "__FK_data",
        (SELECT
            "name",
            "__KEY_venues",
            "__FK_venues",
            (SELECT
                "city",
                "country",
                "countryCode",
                "latitude",
                "longitude",
                "address1",
                "region",
                "regionCode",
                "postalCode",
                "__FK_address"
            FROM "address" FK "__FK_address")
        FROM "venues" PK "__KEY_venues" FK "__FK_venues"),
        (SELECT
            "firstName",
            "lastName",
            "email",
            "prefix",
            "__FK_planners"
        FROM "planners" FK "__FK_planners"),
        (SELECT
            "id",
            "name" AS "name_u0",
            "type",
            "order",
            "__KEY_customFields",
            "__FK_customFields",
            (SELECT
                "@Value",
                "__FK_value"
            FROM "value" FK "__FK_value" ArrayValueAlias "@Value")
        FROM "customFields" PK "__KEY_customFields" FK "__FK_customFields"),
        (SELECT
            "name" AS "name_u1",
            "__FK_category"
        FROM "category" FK "__FK_category"),
        (SELECT
            "__KEY__links_u0",
            "__FK__links_u0",
            (SELECT
                "href" AS "href_u1",
                "__FK_invitation"
            FROM "invitation" FK "__FK_invitation"),
            (SELECT
                "href" AS "href_u2",
                "__FK_agenda"
            FROM "agenda" FK "__FK_agenda"),
            (SELECT
                "href" AS "href_u3",
                "__FK_summary"
            FROM "summary" FK "__FK_summary"),
            (SELECT
                "href" AS "href_u4",
                "__FK_registration"
            FROM "registration" FK "__FK_registration")
        FROM "_links" PK "__KEY__links_u0" FK "__FK__links_u0"),
        (SELECT
            "@Value" AS "@Value_u0",
            "__FK_languages"
        FROM "languages" FK "__FK_languages" ArrayValueAlias "@Value_u0")
    FROM "data" PK "__KEY_data" FK "__FK_data")
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(
QUERY "startAt" "$(startAt)",
URL "https://api-platform.sample.com/sample/sample",
QUERY "filter" "sample.id eq '123456789'",
HTTPHEADER "Authorization" "Bearer $(vToken)"
);

NEXT startAt;

I tried to define the 'total' variable as follows so I can loop through all the records for the specific sample.id used above(948):

LET total=peek('totalCount');
TRACE $(total);

But the result is that it just loads the first 100 records 10 times.

Currently these are the settings of my connection:

Key Generation Strategy - SequenceID
Pagination Type - Custom

I tried also the next token pagination type, but it was also getting only the first 100 records.

My guess is that I have to somehow implement the nextToken and currentToken in the WITH CONNECTION part of my script, problem is that I don't know how to do that and if it is indeed what needs to be done.

Thanks in advance!


问:
Want to move the entire post steps in Jenkins Global Shared library
I am new to Jenkins and I want to use Jenkins shared library for my post build steps so that I don't have to write them again and again but the problem is when I call my groovy method in the post section of the pipeline it gives the following error.

```<code>WorkflowScript: 12: The ‘post’ section can only contain build condition names with code blocks. Valid condition names are [always, changed, fixed, regression, aborted, success, unsuccessful, unstable, failure, notBuilt, cleanup] @ line 12, column 9.
           build()
           ^

WorkflowScript: 11: post can not be empty @ line 11, column 5.
       post {
       ^

2 errors

</code>```

My pipeline syntax:

```<code>@Library("new-library") _
pipeline {
    agent any
    stages {
         stage('Hello') {
            steps {
                   echo 'Hello world!'
            }
        }
    }
    post {
        build()
    }
}
</code>```

build is the name of the groovy file.

My groovy file which is on GitHub

```<code>def call() {
        always {
            echo 'This will always run'
        }

        success {
            echo 'This will run only if successful'
        }

        unstable {
            echo 'This will run only if run was marked as unstable'
        }

        changed {
            echo 'This will run only if the state of the pipeline is changed'
            echo 'FOR EXAMPLE, if the pipeline was previously failed but not it is successful'
        }
   }
</code>```

Simply I want my post steps to be trigger from the Global Shared Library. If there is some other method do let me know as well.

Thank you in advance.

Body:
I am new to Jenkins and I want to use Jenkins shared library for my post build steps so that I don't have to write them again and again but the problem is when I call my groovy method in the post section of the pipeline it gives the following error.

WorkflowScript: 12: The ‘post’ section can only contain build condition names with code blocks. Valid condition names are [always, changed, fixed, regression, aborted, success, unsuccessful, unstable, failure, notBuilt, cleanup] @ line 12, column 9.
           build()
           ^

WorkflowScript: 11: post can not be empty @ line 11, column 5.
       post {
       ^

2 errors

My pipeline syntax:

@Library("new-library") _
pipeline {
    agent any
    stages {
         stage('Hello') {
            steps {
                   echo 'Hello world!'
            }
        }
    }
    post {
        build()
    }
}

build is the name of the groovy file.

My groovy file which is on GitHub

def call() {
        always {
            echo 'This will always run'
        }

        success {
            echo 'This will run only if successful'
        }

        unstable {
            echo 'This will run only if run was marked as unstable'
        }

        changed {
            echo 'This will run only if the state of the pipeline is changed'
            echo 'FOR EXAMPLE, if the pipeline was previously failed but not it is successful'
        }
   }

Simply I want my post steps to be trigger from the Global Shared Library. If there is some other method do let me know as well.

Thank you in advance.


问:
How do I make two subplots with diffrent scales in matplotlib, python?
I wanna make two (sub) plots in one figure, on the first I wanna have log-log scale on second linear-log scale. How do I do that?
Following code doesn't work.</p>
```<code>figure, (ax1,ax2) = plt.subplots(1, 2)

plt.xscale("log")
plt.yscale("log")
ax1.plot(indices,pi_singal,linestyle='-')
plt.xscale("log")
plt.yscale("linear")
ax2.plot(indices,max_n_for_f)

plt.show()
</code>```

Body:
I wanna make two (sub) plots in one figure, on the first I wanna have log-log scale on second linear-log scale. How do I do that?
Following code doesn't work.

figure, (ax1,ax2) = plt.subplots(1, 2)

plt.xscale("log")
plt.yscale("log")
ax1.plot(indices,pi_singal,linestyle='-')
plt.xscale("log")
plt.yscale("linear")
ax2.plot(indices,max_n_for_f)

plt.show()


问:
Inconsistent NYC coverage report
All of a sudden, I'm getting very inconsistent nyc coverage reports, locally, and running in CI with Travis.

When running NYC, it fails locally, and nearly passes on Travis.

More details and config:

package.json bits:

```<code>"scripts": {
  "build": "webpack --mode production",
  "lint": "eslint src/",
  "test": "nyc mocha --exit --forbid-only",
  "verify": "npm run lint && npm run test && npm run build"
},
"dependencies": {
  "core-js": "^3.26.1",
},
"devDependencies": {
  "@babel/core": "^7.20.5",
  "@babel/plugin-transform-runtime": "^7.19.6",
  "@babel/preset-env": "^7.20.2",
  "@babel/preset-react": "^7.18.6",
  "@babel/register": "^7.18.9",
  "babel-loader": "^9.1.0",
  "babel-plugin-istanbul": "^6.1.1",
  "mocha": "^10.2.0",
  "nyc": "^15.1.0",
  "webpack": "^5.75.0",
  "webpack-cli": "^5.0.1",
  "webpack-dev-server": "^4.11.1"
}
</code>```

babel.config.json

```<code>{
  "compact": false,
  "env": {
    "test": {
      "plugins": [
        "istanbul"
      ]
    }
  },
  "presets": [
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "usage",
        "corejs": "3.26"
      }
    ],
    [
      "@babel/preset-react",
      {
        "runtime": "automatic"
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-transform-runtime"
  ]
}
</code>```

.nycrc.json

```<code>{
  "all": true,
  "check-coverage": true,
  "branches": 100,
  "exclude": [
    "src/constants/**/*.js",
    "src/theme/*.js"
  ],
  "functions": 100,
  "include": [
    "src/**/*.js"
  ],
  "lines": 100,
  "reporter": [
    "html",
    "text"
  ],
  "statements": 100
}
</code>```

.mocharc.json

```<code>{
  "file": [
    "./test/testUtils/setupTests.js"
  ],
  "require": [
    "@babel/register",
    "core-js/stable",
    "global-jsdom/register",
    "regenerator-runtime/runtime"
  ],
  "recursive": true
}
</code>```

Problems:

When running locally, I see branches failing across a ton of files for the ELSE path not taken for the last import in a lot of files

When running on Travis, I have files with /* istanbul ignore file */ that are getting flagged for coverage (not honoring the ignore), but do not have the problem mentioned in 1

I've scoured the internet and tried different configurations.  I also tried to use C8 instead of NYC, and get C8 passing locally, but it fails miserably on the server

Title: Inconsistent NYC coverage report

Body:
All of a sudden, I'm getting very inconsistent nyc coverage reports, locally, and running in CI with Travis.

When running NYC, it fails locally, and nearly passes on Travis.

More details and config:

package.json bits:

"scripts": {
  "build": "webpack --mode production",
  "lint": "eslint src/",
  "test": "nyc mocha --exit --forbid-only",
  "verify": "npm run lint && npm run test && npm run build"
},
"dependencies": {
  "core-js": "^3.26.1",
},
"devDependencies": {
  "@babel/core": "^7.20.5",
  "@babel/plugin-transform-runtime": "^7.19.6",
  "@babel/preset-env": "^7.20.2",
  "@babel/preset-react": "^7.18.6",
  "@babel/register": "^7.18.9",
  "babel-loader": "^9.1.0",
  "babel-plugin-istanbul": "^6.1.1",
  "mocha": "^10.2.0",
  "nyc": "^15.1.0",
  "webpack": "^5.75.0",
  "webpack-cli": "^5.0.1",
  "webpack-dev-server": "^4.11.1"
}

babel.config.json

{
  "compact": false,
  "env": {
    "test": {
      "plugins": [
        "istanbul"
      ]
    }
  },
  "presets": [
    [
      "@babel/preset-env",
      {
        "useBuiltIns": "usage",
        "corejs": "3.26"
      }
    ],
    [
      "@babel/preset-react",
      {
        "runtime": "automatic"
      }
    ]
  ],
  "plugins": [
    "@babel/plugin-transform-runtime"
  ]
}

.nycrc.json

{
  "all": true,
  "check-coverage": true,
  "branches": 100,
  "exclude": [
    "src/constants/**/*.js",
    "src/theme/*.js"
  ],
  "functions": 100,
  "include": [
    "src/**/*.js"
  ],
  "lines": 100,
  "reporter": [
    "html",
    "text"
  ],
  "statements": 100
}

.mocharc.json

{
  "file": [
    "./test/testUtils/setupTests.js"
  ],
  "require": [
    "@babel/register",
    "core-js/stable",
    "global-jsdom/register",
    "regenerator-runtime/runtime"
  ],
  "recursive": true
}

Problems:

When running locally, I see branches failing across a ton of files for the ELSE path not taken for the last import in a lot of files

When running on Travis, I have files with /* istanbul ignore file */ that are getting flagged for coverage (not honoring the ignore), but do not have the problem mentioned in 1

I've scoured the internet and tried different configurations.  I also tried to use C8 instead of NYC, and get C8 passing locally, but it fails miserably on the server