问:
Assigning HTML content to a var in Google Spreadsheet Script
I'm trying to execute an automail through a script in Google Spreadsheet to mail all my clients at a single time. But every time I'm trying to run the script it says that I've incorrectly assigned the HTML content to a variable.

The script code for assigning the value was :

```<code>function sendMail(){

  var name = 1;
  var email = 2;
  var userEmail = 3;
  var password = 4;

  var emailTemp = HtmlService.createTemplateFromFile("MailApp");
  var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Copy of OneDrive Cloud Storage");

  var data = ws.getRange("B2:E" + ws.getLastRow()).getValues();

  data.forEach(function(row){
    emailTemp.name = row[name];
    emailTemp.userEmail = row[userEmail];
    emailTemp.password = row[password];
    emailTemp.email = row[email];

    var htmlMessage = emailTemp.evaluate().getContent();

    GmailApp.sendEmail(
      row[email],
      "OneDrive 5TB Storage",
      "Your email doesn't support HTML.",
      {name: "AutoMail by Shovon", htmlBody: htmlMessage}
    );
  });
}
</code>```

An error was in the line: var htmlMessage = emailTemp.evaluate().getContent();
The error message says :

I'm also attaching the HTML code:

```<code><html>
  <head>
    <base target="_top">
  </head>
  <body>
  <p>Dear <b> <?= name ?>, </b> </p>
  <p>I received your <b>OneDrive 5TB Cloud Storage</b> request yesterday. I'm really very sorry for being so late as I had some personal things to do.</p>
  <p>But the good news is I've successfully created the following <b>OneDrive Business Account</b> for you: </p>
  <p> User email:<b> <u><? = userEmail?> </u> </b> <br>
   Password: <b> <?= password?> </b> </p>
   <p> Please login to this <b> Microsoft</b> account as soon as possible and set up 2 steps verification method by using your own email address(e.g. <b> <u> <?= email ?> </u> </b>).</p>
   <p>To login <b> <u> <a href = "https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1590813490&rver=7.0.6738.0&wp=MBI_SSL&wreply=https:%2F%2Faccount.microsoft.com%2Fauth%2Fcomplete-signin%3Fru%3Dhttps%253A%252F%252Faccount.microsoft.com%252F%253Frefp%253Dsignedout-index%2526refd%253Dwww.bing.com&lc=1033&id=292666&lw=1&fl=easi2">click here</a></u></b>.</p>
   <p>Yours,<br>
   <b>Md. Shahariar Shovon</b></p>
  </body>
</html>

</code>```

Please help me solving this issue.

答:
You don't need HtmlService, as "The HTML service lets you serve web pages that can interact with server-side Apps Script functions." and that is its use case.

So just create the HTML using JavaScript and then place it into the body. For example, picture this in your for loop.

```<code>const infoObj = {
  name: row[name],
  email: row[userEmail]
}
const emailBody = createEmailBody( infoObj );
const params = {
   name: "AutoMail by Shovon",
   htmlBody: emailBody.html
}

GmailApp.sendEmail(infoObj.email, subject, emailBody.plain, params);

// here you can create your html body
function createEmailBody( info ) {
  return {
    plain: `Hi ${info.name}, this is your ${info.email}`,
    html: `<div>Hi ${info.name}, this is your email ${info.email} </div>`
  }
}
</code>```

Body:
I'm trying to execute an automail through a script in Google Spreadsheet to mail all my clients at a single time. But every time I'm trying to run the script it says that I've incorrectly assigned the HTML content to a variable.

The script code for assigning the value was :

function sendMail(){

  var name = 1;
  var email = 2;
  var userEmail = 3;
  var password = 4;

  var emailTemp = HtmlService.createTemplateFromFile("MailApp");
  var ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Copy of OneDrive Cloud Storage");

  var data = ws.getRange("B2:E" + ws.getLastRow()).getValues();

  data.forEach(function(row){
    emailTemp.name = row[name];
    emailTemp.userEmail = row[userEmail];
    emailTemp.password = row[password];
    emailTemp.email = row[email];

    var htmlMessage = emailTemp.evaluate().getContent();

    GmailApp.sendEmail(
      row[email],
      "OneDrive 5TB Storage",
      "Your email doesn't support HTML.",
      {name: "AutoMail by Shovon", htmlBody: htmlMessage}
    );
  });
}

An error was in the line: var htmlMessage = emailTemp.evaluate().getContent();
The error message says :

I'm also attaching the HTML code:

    <base target="_top">

Dear  <?= name ?>,

I received your OneDrive 5TB Cloud Storage request yesterday. I'm really very sorry for being so late as I had some personal things to do.

But the good news is I've successfully created the following OneDrive Business Account for you:

 User email: <? = userEmail?>

   Password:  <?= password?>

 Please login to this  Microsoft account as soon as possible and set up 2 steps verification method by using your own email address(e.g.   <?= email ?>  ).

To login   click here.

Yours,

   Md. Shahariar Shovon

Please help me solving this issue.

Body:
You don't need HtmlService, as "The HTML service lets you serve web pages that can interact with server-side Apps Script functions." and that is its use case.

So just create the HTML using JavaScript and then place it into the body. For example, picture this in your for loop.

const infoObj = {
  name: row[name],
  email: row[userEmail]
}
const emailBody = createEmailBody( infoObj );
const params = {
   name: "AutoMail by Shovon",
   htmlBody: emailBody.html
}

GmailApp.sendEmail(infoObj.email, subject, emailBody.plain, params);

// here you can create your html body
function createEmailBody( info ) {
  return {
    plain: `Hi ${info.name}, this is your ${info.email}`,
    html: `<div>Hi ${info.name}, this is your email ${info.email} </div>`
  }
}


来源: stackexchange

问:
What is the difference between node.js runtime and npm package manager options while installing node.JS?
I am trying to install node.js by downloading the .exe file, I am confused and stuck on the Node.js setup where in it asks to install node.js runtime or npm package manager  so I want to proceed through the installation after knowing fully the difference between the two.

My question is what is the difference between node.js runtime and npm
  pacakage manager and what are all the features do I get on the two
  options.

My basic purpose of installing node.js is to compile Typescript, Please help me to understand the features of the two package

答:
Node.js or Node is an open-source, cross-platform, JavaScript runtime environment(JSRE) that executes JavaScript code outside of a web browser.

npm is a package manager(like Nuget package manager in .NET -Microsoft ) for the JavaScript programming language. It is the default package manager for the JavaScript runtime environment Node.js.

You can differentiate them by finding their version using below code.

```<code>node --version

npm --version
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Node.js or Node is an open-source, cross-platform, JavaScript runtime environment(JSRE) that executes JavaScript code outside of a web browser.

npm is a package manager(like Nuget package manager in .NET -Microsoft ) for the JavaScript programming language. It is the default package manager for the JavaScript runtime environment Node.js.

You can differentiate them by finding their version using below code.

node --version

npm --version


问:
Unable to Flash eMMC from SD Card BeagleBone Black
I am working on BeagleBone Black and Debian running on it. I want to flash latest Debian image on my board. To do so I have downloaded a latest Debian image from link:BeagleBone Image and prepared an SD card using WinDisk image writer.

As per tutorial I have inserted an SD card into the BeagleBone Black, pressed boot button and applied power. SD card image has booted. According to the tutorial flashing eMMC takes about 30-40 minutes, so I waited for about 2 hours (just to be sure). Then I removed an SD card from my board and power it on. It booted my previous image (eMMC was not Flashed by SD card image). For flashing eMMC I am following the link: Flashing beagleBone Balck eMMC.

I am unable to understand where I am getting wrong and how to resolve it.

答:
For those who still have issues, you can also try updating the flasher scripts

```<code>cd /opt/scripts/
git pull
shutdown -r now
</code>```

This will update a bunch of stuff, I don't know what all it will update, but things sometimes seem to work better after ie even though I'm on Wheezy 7.10 when I apt-get update I now pull from Jessie, and things install properly. I believe that my flasher scripts on the EMMC were messed up and this may have fixed them.

This may also overwrite your /boot/uEnv.txt file with a stock / default version, so make sure to go back in and edit /boot/uEnv.txt by uncommenting the line #cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh so that your flasher will run from your SD Card/

I've been fighting trying to update my BB Black and Greens, this seems to be a necessary step for 4 of them so far, all coming from wither Wheezy 7.10 or Jessie 8.

After running it and letting it update things, power down, add SD card, hold button, add power...see what happens.

ContentLicense: CC BY-SA 3.0

Body:
For those who still have issues, you can also try updating the flasher scripts

cd /opt/scripts/
git pull
shutdown -r now

This will update a bunch of stuff, I don't know what all it will update, but things sometimes seem to work better after ie even though I'm on Wheezy 7.10 when I apt-get update I now pull from Jessie, and things install properly. I believe that my flasher scripts on the EMMC were messed up and this may have fixed them.

This may also overwrite your /boot/uEnv.txt file with a stock / default version, so make sure to go back in and edit /boot/uEnv.txt by uncommenting the line #cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh so that your flasher will run from your SD Card/

I've been fighting trying to update my BB Black and Greens, this seems to be a necessary step for 4 of them so far, all coming from wither Wheezy 7.10 or Jessie 8.

After running it and letting it update things, power down, add SD card, hold button, add power...see what happens.


问:
ajaxStart fails on subsequent requests when using getJSON
I'm trying to use the ajaxStart and ajaxStop events with getJson calls to my webserver.  The ajaxStart event is triggered on the first request, but not on subsequent requests.  The encID ensures that each requested url is somewhat unique.  It doesn't work on Firefox 3.5 or IE 7.  In firebug, I can see the the getJSON requests are firing and completing.  Any ideas?

Here are my ajax event bindings.

```<code>$('#ajaxLoader').ajaxStart(function(){
   $(this).show();
}).ajaxStop(function(){
   $(this).hide();
});
</code>```

Here is my getJSON call.

```<code>$.getJSON(location.protocol + '//' + location.host + '/enc-comment/get?format=json&c=?' + '&encId=' + encId,
function(data){
   // change text of a div
});
</code>```

If I switch the getJSON call with a .ajax GET or POST, everything works fine.

答:
I'm guessing Yashwant is referring to interrupting automatic browser caching using a random parameter.

A prettier way of doing this is to just use $.ajaxSetup()

```<code>$.ajaxSetup({ cache: false });
</code>```

This will block browser caching for all your ajax calls.

ContentLicense: CC BY-SA 2.5

Body:
I'm trying to use the ajaxStart and ajaxStop events with getJson calls to my webserver.  The ajaxStart event is triggered on the first request, but not on subsequent requests.  The encID ensures that each requested url is somewhat unique.  It doesn't work on Firefox 3.5 or IE 7.  In firebug, I can see the the getJSON requests are firing and completing.  Any ideas?

Here are my ajax event bindings.

$('#ajaxLoader').ajaxStart(function(){
   $(this).show();
}).ajaxStop(function(){
   $(this).hide();
});

Here is my getJSON call.

$.getJSON(location.protocol + '//' + location.host + '/enc-comment/get?format=json&c=?' + '&encId=' + encId,
function(data){
   // change text of a div
});

If I switch the getJSON call with a .ajax GET or POST, everything works fine.

Body:
I'm guessing Yashwant is referring to interrupting automatic browser caching using a random parameter.

A prettier way of doing this is to just use $.ajaxSetup()

$.ajaxSetup({ cache: false });

This will block browser caching for all your ajax calls.


问:
How to print in the first input?
When i run this code.

```<code>
number = int(input())
collect = [] #collect number from input
for i in range(number):
  x = int(input())
  collect.append(x)
print(collect)
for j in [ele for ind, ele in enumerate(collect,1) if ele not in collect[ind:]]:
    count = 0
    for ele in collect:
        if j == el:
            count += 1
        else:
            pass
    if count != 0:
        print("{} : {} Items".format(ind, count))
    else:
        print("{} : {} Item".format(j, count))
</code>```

```<code>**input:**  5
             2
             1
             2
             1
             2

**output:**

5

2
1
2
1
2

[2, 1, 2, 1, 2]

1 : 2 Items

2 : 3 Items
</code>```

I would like to show

output:

```<code>5

2
1
2
1
2

[2, 1, 2, 1, 2]

2 : 3 Items
1 : 2 Items

</code>```

How to do it

答:
You may try this:</p>

```<code>number = int(input())
collect = [] #collect number from input
for i in range(number):
  x = int(input())
  collect.append(x)
print(collect)

from collections import Counter

counter = Counter(collect)
for a,b in sorted([v,k for k,v in counter.items()], reverse=True) :
    print("{} : {} Item{}".format(b, a, 's' if a != 1 else ''))
</code>```

Title: How to print in the first input?

Body:
When i run this code.

number = int(input())
collect = [] #collect number from input
for i in range(number):
  x = int(input())
  collect.append(x)
print(collect)
for j in [ele for ind, ele in enumerate(collect,1) if ele not in collect[ind:]]:
    count = 0
    for ele in collect:
        if j == el:
            count += 1
        else:
            pass
    if count != 0:
        print("{} : {} Items".format(ind, count))
    else:
        print("{} : {} Item".format(j, count))

**input:**  5
             2
             1
             2
             1
             2

**output:**

5

2
1
2
1
2

[2, 1, 2, 1, 2]

1 : 2 Items

2 : 3 Items

I would like to show

output:

5

2
1
2
1
2

[2, 1, 2, 1, 2]

2 : 3 Items
1 : 2 Items

How to do it

Body:
You may try this:

number = int(input())
collect = [] #collect number from input
for i in range(number):
  x = int(input())
  collect.append(x)
print(collect)

from collections import Counter

counter = Counter(collect)
for a,b in sorted([v,k for k,v in counter.items()], reverse=True) :
    print("{} : {} Item{}".format(b, a, 's' if a != 1 else ''))


问:
React conditional rendering only partially happening
I have a react component that is displaying the results of an array as a Badge (from Bootstrap React library). In the condition, I'm checking if the length of array is greater than zero and rendering the results using a map function. I wanted to add additional text to also display on the condition but for some reason it is not displaying the h1 tag yet the badges are being displayed. Why isn't it displaying the h1 tag??

```<code>render() {
   const arr = this.state.items;
   return(
    <Card>
     <Card.Body>
      <div>
       {arr.length > 0 && <h1>Additional Text</h1> &&
        arr.map((item) =>
        <Badge key={item.toString()} pill variant='primary'>
          {item}
        </Badge>
       }
     </div>
    </Card.Body>
   </Card>
);
</code>```

答:
From what I see you are trying to use conditional statements wrong. From the docs here.

expr1 && expr2 means If expr1 can be converted to true, returns expr2; else, returns expr1.

i.e your first expression arr.length > 0 returns true so,
    your second expression is evaluated
...
 which is also evaluated true. Therefore, final expression is evaluated and returned.

So to display both the components you could use fragments or as others have suggested using multiple conditionals or wrapping in a div.

```<code>{
  arr.length > 0 &&
  <>
  <h1>Additional Text</h1>
  {
     arr.map((item) =>
        <Badge key={item.toString()} pill variant='primary'>
          {item}
        </Badge>
  }
  </>
}
</code>```

Here, <> and </> are shorthands for <React.Fragment> and </React.Fragment> and will give you the same tree structure you might have wanted.

Body:
I have a react component that is displaying the results of an array as a Badge (from Bootstrap React library). In the condition, I'm checking if the length of array is greater than zero and rendering the results using a map function. I wanted to add additional text to also display on the condition but for some reason it is not displaying the h1 tag yet the badges are being displayed. Why isn't it displaying the h1 tag??

render() {
   const arr = this.state.items;
   return(
    <Card>
     <Card.Body>

       {arr.length > 0 &&
Additional Text
 &&
        arr.map((item) =>
        <Badge key={item.toString()} pill variant='primary'>
          {item}
        </Badge>
       }

    </Card.Body>
   </Card>
);

Body:
From what I see you are trying to use conditional statements wrong. From the docs here.

expr1 && expr2 means If expr1 can be converted to true, returns expr2; else, returns expr1.

i.e your first expression arr.length > 0 returns true so,
    your second expression is evaluated <h1>...</h1> which is also evaluated true. Therefore, final expression is evaluated and returned.

So to display both the components you could use fragments or as others have suggested using multiple conditionals or wrapping in a div.

{
  arr.length > 0 &&
  <>
  <h1>Additional Text</h1>
  {
     arr.map((item) =>
        <Badge key={item.toString()} pill variant='primary'>
          {item}
        </Badge>
  }
  </>
}

Here, <> and </> are shorthands for <React.Fragment> and </React.Fragment> and will give you the same tree structure you might have wanted.


问:
Zend_Date tooooooooo slow, real slow
This is my code:

```<code>$frontendOptions = array('lifeTime' => 10);
$backendOptions = array('cacheDir' => '../tmp/');

$cache = Zend_Cache::factory(   'Core',
                                'File',
                                $frontendOptions,
                                $backendOptions);

$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);

$locale = new Zend_Locale('es_ES');
Zend_Registry::set('Zend_Locale', $locale);
Zend_Locale::setCache($cache);

$date = new Zend_Date('11-03-2010');
</code>```

The script slows down when I try to create the Zend_Date object.

I'm using Zend 1.11.5 on MAMP (Mac / Snow Leopard).

Does anyone have any idea how can I speed up this?

答:
Zend_Date and a few other Zend classes are known to be slow.  You can speed-up subsequent calls to Zend_Date by using your cache:

```<code>$date = new Zend_Date(...);
 ....
$cachedDate = new Cache($date);
print $cachedDate->toString();
</code>```

I know this will sound simplistic but if you just need a formatted regular date, just use php's built-in date object. I guarantee you will see a major speed difference.

UPDATE:

If you really want to tweak the class to improve performance, this post has a couple of patches / tweaks you can apply.

Title: Zend_Date tooooooooo slow, real slow

Body:
This is my code:

$frontendOptions = array('lifeTime' => 10);
$backendOptions = array('cacheDir' => '../tmp/');

$cache = Zend_Cache::factory(   'Core',
                                'File',
                                $frontendOptions,
                                $backendOptions);

$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);

$locale = new Zend_Locale('es_ES');
Zend_Registry::set('Zend_Locale', $locale);
Zend_Locale::setCache($cache);

$date = new Zend_Date('11-03-2010');

The script slows down when I try to create the Zend_Date object.

I'm using Zend 1.11.5 on MAMP (Mac / Snow Leopard).

Does anyone have any idea how can I speed up this?

Body:
Zend_Date and a few other Zend classes are known to be slow.  You can speed-up subsequent calls to Zend_Date by using your cache:

$date = new Zend_Date(...);
 ....
$cachedDate = new Cache($date);
print $cachedDate->toString();

I know this will sound simplistic but if you just need a formatted regular date, just use php's built-in date object. I guarantee you will see a major speed difference.

UPDATE:

If you really want to tweak the class to improve performance, this post has a couple of patches / tweaks you can apply.


问:
Do I need Windows 10 Pro to run Docker? Error: Hardware assisted virtualization and data execution protection must be enabled in the BIOS
I just installed Docker after upgrading my Windows 10 Home x64 to the version 2004 with the OS build 19041.264 (I needed to upgrade because Docker required me to have an OS buld >19018). Now if I want to launch docker I get this error Hardware assisted virtualization and data execution protection must be enabled in the BIOS. I have already read this (it is old) question, but because they let me install docker on my windows 10 home I assume that I can somehow run it without hyper-v, cuz I can't download it.

答: You will need Windows 10 Pro to run docker. Home edition is not useful for the purpose.</p>


问:
Show Product sale end date on Woocommerce Product Page
I have this code but it seems outdated

```<code>add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
global $product;
function custom_price_html( $price, $product ) {

if ( is_single() && $product->is_on_sale() && $sales_price_to != "" ) {

$sales_price_from = $product->get_date_on_sale_from();
$sales_price_to   = $product->get_date_on_sale_to();

if( ! empty($sales_price_from) || ! empty($sales_price_to) ){
    $sales_price_date_to   = $sales_price_from->date( "j.m.Y");
    $sales_price_date_from = $sales_price_to->date( "j.m.Y");
    $sales_date = '<p class="offer_date">Angebot vom '.$sales_price_date_from.' bis '.$sales_price_date_to.'</p>';
} else {
    $sales_date = $sales_price_from = $sales_price_to = '';
}

    $price = str_replace( '</ins>', ' </ins> <b>(Offer from ' . $sales_price_date_from . ' till ' . $sales_price_date_to . ')</b>', $price );
}

return $price;
}
</code>```

I want to display sale end date for simple and variable products.

答:
You're using the $sales_price_to variable when it's not defined. Please use the below code, tested and works perfectly.</p>

```<code>add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
function custom_price_html( $price, $product ) {

if ( is_single() && $product->is_on_sale() ) {
$sales_price_from = $product->get_date_on_sale_from();
$sales_price_to   = $product->get_date_on_sale_to();
if( ! empty($sales_price_from) || ! empty($sales_price_to) ){
    $sales_price_date_from   = $sales_price_from->date( "j.m.Y");
    $sales_price_date_to = $sales_price_to->date( "j.m.Y");
    $sales_date = '<p class="offer_date">Angebot vom '.$sales_price_date_from.' bis '.$sales_price_date_to.'</p>';
} else {
    $sales_date = $sales_price_from = $sales_price_to = '';
}

    $price = str_replace( '</ins>', ' </ins> <b>(Offer from ' . $sales_price_date_from . ' till ' . $sales_price_date_to . ')</b>', $price );
}

return $price;
}
</code>```

Body:
I have this code but it seems outdated

add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
global $product;
function custom_price_html( $price, $product ) {

if ( is_single() && $product->is_on_sale() && $sales_price_to != "" ) {

$sales_price_from = $product->get_date_on_sale_from();
$sales_price_to   = $product->get_date_on_sale_to();

if( ! empty($sales_price_from) || ! empty($sales_price_to) ){
    $sales_price_date_to   = $sales_price_from->date( "j.m.Y");
    $sales_price_date_from = $sales_price_to->date( "j.m.Y");
    $sales_date = '
Angebot vom '.$sales_price_date_from.' bis '.$sales_price_date_to.'
';
} else {
    $sales_date = $sales_price_from = $sales_price_to = '';
}

    $price = str_replace( '', '  (Offer from ' . $sales_price_date_from . ' till ' . $sales_price_date_to . ')', $price );
}

return $price;
}

I want to display sale end date for simple and variable products.

Body:
You're using the $sales_price_to variable when it's not defined. Please use the below code, tested and works perfectly.

add_filter( 'woocommerce_get_price_html', 'custom_price_html', 100, 2 );
function custom_price_html( $price, $product ) {

if ( is_single() && $product->is_on_sale() ) {
$sales_price_from = $product->get_date_on_sale_from();
$sales_price_to   = $product->get_date_on_sale_to();
if( ! empty($sales_price_from) || ! empty($sales_price_to) ){
    $sales_price_date_from   = $sales_price_from->date( "j.m.Y");
    $sales_price_date_to = $sales_price_to->date( "j.m.Y");
    $sales_date = '<p class="offer_date">Angebot vom '.$sales_price_date_from.' bis '.$sales_price_date_to.'</p>';
} else {
    $sales_date = $sales_price_from = $sales_price_to = '';
}

    $price = str_replace( '</ins>', ' </ins> <b>(Offer from ' . $sales_price_date_from . ' till ' . $sales_price_date_to . ')</b>', $price );
}

return $price;
}


问:
Why the return value of my function is undefined?
guys, I'm just starting in the coding world. Now I'm learning JavaScript, so I have a problem, I have a function that is going to ask the user for the name.

Then I want to create another function using the name for ask for an integer, so when I try to call the return values from the first function is giving me undefined.

This is my code:

```<code>function getUsername() {
    var f1CustomerName;

    f1CustomerName = prompt("Please enter your name", "Type Here");
    // window.alert("f1CustomerName is: " + f1CustomerName );

    if ( f1CustomerName == null ) {
        return;
    } else if( f1CustomerName == "Type Here" || f1CustomerName == "" ) {
        return;
    } else {
        //window.alert("Hello " + f1CustomerName + "!");
        return f1CustomerName;
    }
}

var nameUser = getUsername();

// ...

function getinteger(nameUser) {
    var integer=prompt(nameUser + " Please enter an integer");
    window.alert("Hello this is your integer: " + integer + "!");
}

getinteger();
</code>```

答:
You should give the function the variable of nameUser to use it when calling it in the last line:</p>

```<code>getinteger(nameUser);
</code>```

Body:
guys, I'm just starting in the coding world. Now I'm learning JavaScript, so I have a problem, I have a function that is going to ask the user for the name.

Then I want to create another function using the name for ask for an integer, so when I try to call the return values from the first function is giving me undefined.

This is my code:

function getUsername() {
    var f1CustomerName;

    f1CustomerName = prompt("Please enter your name", "Type Here");
    // window.alert("f1CustomerName is: " + f1CustomerName );

    if ( f1CustomerName == null ) {
        return;
    } else if( f1CustomerName == "Type Here" || f1CustomerName == "" ) {
        return;
    } else {
        //window.alert("Hello " + f1CustomerName + "!");
        return f1CustomerName;
    }
}

var nameUser = getUsername();

// ...

function getinteger(nameUser) {
    var integer=prompt(nameUser + " Please enter an integer");
    window.alert("Hello this is your integer: " + integer + "!");
}

getinteger();

Body:
You should give the function the variable of nameUser to use it when calling it in the last line:

getinteger(nameUser);


问:
AWS best way to handle high volume transactions
I am writing a system that has extremely high volume of transactions, CRUD and I am working with AWS. What are the considerations that I must keep in mind given that none of the data should be lost?

I have done some research and they say to use SQS queues to make sure that data is not lost. What other backup, redundancy, quick processing considerations should I keep in mind?

答:
So if you want to create a system that is highly resilient, whilst also being redundant I would advise you to take a read of the AWS Well Architected Framework. This will go into more detail that a person can provide on stack overflow.

Regarding individual technologies:

If you're transactional like you said, then you should look at using a relational data store for storing the data. I'd recommend taking a look at Amazon Aurora, it has built in features like auto scaling of read onlys and multi master support. Whilst you might be expecting large number, by using autoscaling you will only pay for what you use.

Try to decouple your APIs, have a dumb validation layer before handing off to your backend if you can help it. Technologies like SQS (as you mentioned before) help with decoupling when you combine with Lambda.

SQS guarantees at least once, so if your system should not write duplicates you'll want to account for idempotency in your application.

Also use a dead letter queue (DLQ) to handle any failed actions.

Ensure any resources residing in your VPC are spread across availability zones.

Use S3, EC2 Backup Manager and RDS snapshots to ensure data is backed up. Most other services has some sort of backup functionality you can enable.

Use autoscaling wherever possible to ensure you're reducing costs.

Build any infrastructure using an IaC tool (CloudFormation or Terraform), and any provisioning of resources via a tool like (Ansible, Puppet, Chef). Try to follow a pre baked AMI workflow to ensure that it is quick to return to the base server state.


问:
Accessing a list with only recursion and lambdas
As part of my homework I have to access every element o a list without a for loop to use it in a function I'm allowed to use, e.g:

```<code>myList=['Hello','World']
</code>```

I've tried using lambda functions (Because I'm not allowed to declare functions with Def) but didn't work.

```<code>function(next(myList))
</code>```

Also tried using next(myList) but sometimes the list can have 1000+ elements.

答:
Using map is the shortest way to do it. You don't need lambda.</p>

```<code>li = list(range(10)) # this is your list
list(map(print, li)) # view each element
</code>```

Body:
As part of my homework I have to access every element o a list without a for loop to use it in a function I'm allowed to use, e.g:

myList=['Hello','World']

I've tried using lambda functions (Because I'm not allowed to declare functions with Def) but didn't work.

function(next(myList))

Also tried using next(myList) but sometimes the list can have 1000+ elements.

Body:
Using map is the shortest way to do it. You don't need lambda.

li = list(range(10)) # this is your list
list(map(print, li)) # view each element


答:
You get undefined when no value is explicitly returned.

Your existing code can be drastically simplified.

function getUsername() {
  return prompt("Please enter your name") || null;
}
function getinteger(nameUser) {
  if (!nameUser) {return;}
  const integer = prompt(`${nameUser} Please enter an integer`);
  window.alert(`Hello this is your integer: ${integer}!`);
}

getinteger(
  getUsername()
);```

Title: Why the return value of my function is undefined?


问:
Sort the array according to the alphabetic order of the last names of the students
Sort the array according to the alphabetic order of the last names of the students and print the array to the console.

But the code does not show the output correctly, why?

If i give input. Suppose,

input:

```<code>Enter the value of number: 2
Please enter the name of the student:
Nihan ahmed
</code>```

output:

```<code>After sorting the array:
Nihan ahmed
</code>```

Why can't I input more than one name?

```<code>#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
void main()
{
    char name[10][8], temp[8];
    int i,j,n,L,k;
    printf("Enter the value of number:\n");
    scanf("%d", &n);
    fflush(stdin);
    printf("\n");
    printf("Please enter the name of the student:\n");
    for(i=0;i<n;i++)
    {
        gets(name[i]);
    }
    for(i=0;i<n-1;i++)
    {
        k=0;
        while(1)
        {
            ++k;
            if(name[i][k]==' ')
            break;
        }
        for(j=i+1;j<n;j++)
        {
           L=0;
           while(1)
           {
               ++L;
               if(name[j][L]==' ')
               break;
           }
            if(name[i][k+1]>name[j][L+1])
            {
               strcpy(temp,name[i]);
               strcpy(name[i],name[j]);
               strcpy(name[j],temp);
            }
        }
    }
    printf("After sorting the array:\n");
    for(i=0;i<n;i++)
    {
        puts(name[i]);
    }
    return 0;
}
</code>```

答:
Here : gets(name[i]); is have some limitation related to get input from user.
I advice to use scanf(" %s", name[i]) .
In your code if you put print in

```<code>for(i=0;i<n;i++)
{
    printf("%d \n", i);
    gets(name[i]);
}

OUTPUT:
Enter the value of number:
2

Please enter the name of the student:
0
1
hello
After sorting the array:

hello
</code>```

You will find that 0, 1 print will come at a time in stand of 0 -> (wait for input) -> 1 -> (wait for input).

if you use scanf in stand of gets code work as expected.
please change the code of gets loop with :

```<code>for(i=0;i<n;i++)
{
    scanf("%s",name[i]);
}

OUTPUT:
Enter the value of number:
2

Please enter the name of the student:
hello
abcd
After sorting the array:
hello
abcd
</code>```

Body:
Sort the array according to the alphabetic order of the last names of the students and print the array to the console.

But the code does not show the output correctly, why?

If i give input. Suppose,

input:

Enter the value of number: 2
Please enter the name of the student:
Nihan ahmed

output:

After sorting the array:
Nihan ahmed

Why can't I input more than one name?

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
void main()
{
    char name[10][8], temp[8];
    int i,j,n,L,k;
    printf("Enter the value of number:\n");
    scanf("%d", &n);
    fflush(stdin);
    printf("\n");
    printf("Please enter the name of the student:\n");
    for(i=0;i<n;i++)
    {
        gets(name[i]);
    }
    for(i=0;i<n-1;i++)
    {
        k=0;
        while(1)
        {
            ++k;
            if(name[i][k]==' ')
            break;
        }
        for(j=i+1;j<n;j++)
        {
           L=0;
           while(1)
           {
               ++L;
               if(name[j][L]==' ')
               break;
           }
            if(name[i][k+1]>name[j][L+1])
            {
               strcpy(temp,name[i]);
               strcpy(name[i],name[j]);
               strcpy(name[j],temp);
            }
        }
    }
    printf("After sorting the array:\n");
    for(i=0;i<n;i++)
    {
        puts(name[i]);
    }
    return 0;
}

Body:
Here : gets(name[i]); is have some limitation related to get input from user.
I advice to use scanf(" %s", name[i]) .
In your code if you put print in

for(i=0;i<n;i++)
{
    printf("%d \n", i);
    gets(name[i]);
}

OUTPUT:
Enter the value of number:
2

Please enter the name of the student:
0
1
hello
After sorting the array:

hello

You will find that 0, 1 print will come at a time in stand of 0 -> (wait for input) -> 1 -> (wait for input).

if you use scanf in stand of gets code work as expected.
please change the code of gets loop with :

for(i=0;i<n;i++)
{
    scanf("%s",name[i]);
}

OUTPUT:
Enter the value of number:
2

Please enter the name of the student:
hello
abcd
After sorting the array:
hello
abcd


答:
Just return values from your if-else statements

```<code>function getUsername() {
    var f1CustomerName;

    f1CustomerName = prompt("Please enter your name", "Type Here");
    //window.alert("f1CustomerName is: " + f1CustomerName );

    if (f1CustomerName == null) {
        return f1CustomerName;
    } else if (f1CustomerName == "Type Here" || f1CustomerName == "") {
        return f1CustomerName;
    } else {
        //window.alert("Hello " + f1CustomerName + "!");
        return f1CustomerName;
    }
}
</code>```

Also you should pass some argument to your getinteger function.

Body:
Just return values from your if-else statements

function getUsername() {
    var f1CustomerName;

    f1CustomerName = prompt("Please enter your name", "Type Here");
    //window.alert("f1CustomerName is: " + f1CustomerName );

    if (f1CustomerName == null) {
        return f1CustomerName;
    } else if (f1CustomerName == "Type Here" || f1CustomerName == "") {
        return f1CustomerName;
    } else {
        //window.alert("Hello " + f1CustomerName + "!");
        return f1CustomerName;
    }
}

Also you should pass some argument to your getinteger function.


问:
Problems while trying to install recaptcha gem on Ruby on Rails 3
Im trying to install recaptcha on a Rails3 app (Im using Passenger), this is what I did:

1) gem install recaptcha

2) In Gemfile I wrote:

gem 'recaptcha', "0.3.1", :require => 'recaptcha/rails'

3) In the controller where Im going to use it I wrote:

require 'net/http'

But when I do: bundle install, it says "Killed", and when I try to run the web app, it says:

Could not find gem 'recaptcha (= 0.3.1, runtime)' in any of the gem sources. (Bundler::GemNotFound)

What should I do? thanks in advance!

答:
You don't need to do 'gem install...'; just run 'bundle install' and bundler will fetch everything it needs to satisfy the requirements you specify in your Gemfile.

The 'killed' bit is new to me. Are you running this on a hosted service by any chance? If so, bundler could be getting killed if it's using too much memory. That page advises you to use bundle package before deployment.


问:
assigning the returning function
I'm new to javascript, and I saw code like this.

```<code><button onclick="this.onClickDoSmth">Click me</button>

onClickDoSmth = () => {
let a = this.clicked();
a();
}

clicked = () => {
console.log("test");
}
</code>```

What's the difference of replacing the expression for "a" to

```<code>onClickDoSmth = () => {
this.clicked();
}
</code>```

答: The former uses assigns a function and calls that variable if you want to reuse again. The latter just calls the function immediately. Both will achieve the same output. </p>

Title: assigning the returning function

Body:
I'm new to javascript, and I saw code like this.

<button onclick="this.onClickDoSmth">Click me</button>

onClickDoSmth = () => {
let a = this.clicked();
a();
}

clicked = () => {
console.log("test");
}

What's the difference of replacing the expression for "a" to

onClickDoSmth = () => {
this.clicked();
}


问:
Changing output of speedtest.py and speedtest-cli to include IP address in output .csv file
I added a line in the python code “speedtest.py” that I found at pimylifeup.com.  I hoped it would allow me to track the internet provider and IP address along with all the other speed information his code provides. But when I execute it, the code only grabs the next word after the find all call. I would also like it to return the IP address that appears after the provider. I have attached the code below. Can you help me modify it to return what I am looking for.

Here is an example what is returned by speedtest-cli

```<code>$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from Biglobe (111.111.111.111)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by GLBB Japan (Naha) [51.24 km]: 118.566 ms
Testing download speed................................................................................
Download: 4.00 Mbit/s
Testing upload speed......................................................................................................
Upload: 13.19 Mbit/s
$
</code>```

And this is an example of what it is being returned by speediest.py to my .csv file

```<code>Date,Time,Ping,Download (Mbit/s),Upload(Mbit/s),myip

05/30/20,12:47,76.391,12.28,19.43,Biglobe
</code>```

This is what I want it to return.

```<code>Date,Time,Ping,Download (Mbit/s),Upload (Mbit/s),myip

05/30/20,12:31,75.158,14.29,19.54,Biglobe 111.111.111.111
</code>```

Or may be,

```<code>05/30/20,12:31,75.158,14.29,19.54,Biglobe,111.111.111.111
</code>```

Here is the code that I am using.  And thank you for any help you can provide.

```<code>import os
import re
import subprocess
import time

response = subprocess.Popen(‘/usr/local/bin/speedtest-cli’, shell=True, stdout=subprocess.PIPE).stdout.read().decode(‘utf-8’)

ping = re.findall(‘km]:\s(.*?)\s’, response, re.MULTILINE)
download = re.findall(‘Download:\s(.*?)\s’, response, re.MULTILINE)
upload = re.findall(‘Upload:\s(.*?)\s’, response, re.MULTILINE)
myip = re.findall(‘from\s(.*?)\s’, response, re.MULTILINE)

ping = ping[0].replace(‘,’, ‘.’)
download = download[0].replace(‘,’, ‘.’)
upload = upload[0].replace(‘,’, ‘.’)
myip = myip[0]

try:
f = open(‘/home/pi/speedtest/speedtestz.csv’, ‘a+’)
if os.stat(‘/home/pi/speedtest/speedtestz.csv’).st_size == 0:
f.write(‘Date,Time,Ping,Download (Mbit/s),Upload (Mbit/s),myip\r\n’)
except:
pass

f.write(‘{},{},{},{},{},{}\r\n’.format(time.strftime(‘%m/%d/%y’), time.strftime(‘%H:%M’), ping, download, upload, myip))
</code>```

答:
```<code>$/usr/local/bin/speedtest-cli --csv-header > speedtestz.csv
$/usr/local/bin/speedtest-cli --csv >> speedtestz.csv
</code>```

output:

Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload,Share,IP Address

Does that not get you what you're looking for? Run the first command once to create the csv with header row. Then subsequent runs are done with the append '>>` operator, and that'll add a test result row each time you run it

Doing all of those regexs will bite you if they or a library that they depend on decides to change their debugging output format

Plenty of ways to do it though. Hope this helps

Body:
I added a line in the python code “speedtest.py” that I found at pimylifeup.com.  I hoped it would allow me to track the internet provider and IP address along with all the other speed information his code provides. But when I execute it, the code only grabs the next word after the find all call. I would also like it to return the IP address that appears after the provider. I have attached the code below. Can you help me modify it to return what I am looking for.

Here is an example what is returned by speedtest-cli

$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from Biglobe (111.111.111.111)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by GLBB Japan (Naha) [51.24 km]: 118.566 ms
Testing download speed................................................................................
Download: 4.00 Mbit/s
Testing upload speed......................................................................................................
Upload: 13.19 Mbit/s
$

And this is an example of what it is being returned by speediest.py to my .csv file

Date,Time,Ping,Download (Mbit/s),Upload(Mbit/s),myip

05/30/20,12:47,76.391,12.28,19.43,Biglobe

This is what I want it to return.

Date,Time,Ping,Download (Mbit/s),Upload (Mbit/s),myip

05/30/20,12:31,75.158,14.29,19.54,Biglobe 111.111.111.111

Or may be,

05/30/20,12:31,75.158,14.29,19.54,Biglobe,111.111.111.111

Here is the code that I am using.  And thank you for any help you can provide.

import os
import re
import subprocess
import time

response = subprocess.Popen(‘/usr/local/bin/speedtest-cli’, shell=True, stdout=subprocess.PIPE).stdout.read().decode(‘utf-8’)

ping = re.findall(‘km]:\s(.*?)\s’, response, re.MULTILINE)
download = re.findall(‘Download:\s(.*?)\s’, response, re.MULTILINE)
upload = re.findall(‘Upload:\s(.*?)\s’, response, re.MULTILINE)
myip = re.findall(‘from\s(.*?)\s’, response, re.MULTILINE)

ping = ping[0].replace(‘,’, ‘.’)
download = download[0].replace(‘,’, ‘.’)
upload = upload[0].replace(‘,’, ‘.’)
myip = myip[0]

try:
f = open(‘/home/pi/speedtest/speedtestz.csv’, ‘a+’)
if os.stat(‘/home/pi/speedtest/speedtestz.csv’).st_size == 0:
f.write(‘Date,Time,Ping,Download (Mbit/s),Upload (Mbit/s),myip\r\n’)
except:
pass

f.write(‘{},{},{},{},{},{}\r\n’.format(time.strftime(‘%m/%d/%y’), time.strftime(‘%H:%M’), ping, download, upload, myip))

Body:
$/usr/local/bin/speedtest-cli --csv-header > speedtestz.csv
$/usr/local/bin/speedtest-cli --csv >> speedtestz.csv

output:

Server ID,Sponsor,Server Name,Timestamp,Distance,Ping,Download,Upload,Share,IP Address

Does that not get you what you're looking for? Run the first command once to create the csv with header row. Then subsequent runs are done with the append '>>` operator, and that'll add a test result row each time you run it

Doing all of those regexs will bite you if they or a library that they depend on decides to change their debugging output format

Plenty of ways to do it though. Hope this helps


问:
COMMITTING_TOP_LEVEL_VALUES_NOT_SUPPORTED: Javers exception, springboot and mongodb
I am using javers in my spring boot with Mongodb, when updating or deleting I get the error COMMITTING_TOP_LEVEL_VALUES_NOT_SUPPORTED:Committing top-level ValueTypes like 'String' is not supported. You can commit only Entity or ValueObject instance.

this is my document class for mongodb

```<code>@Document("admin_users")
public class Admin_users {

@Id
private ObjectId _id;

@Indexed(unique = true)
private String userName;

private String password;
@CreatedDate
private Date dateCreated;
@LastModifiedDate
private Date dateModified;

@Indexed(unique = true)
private String emailAddress;

private String firstName;
private String lastName;
@Version
private Long version;
</code>```

this is my repository

```<code>@JaversSpringDataAuditable
@Repository
public interface AdminUsersRepository extends MongoRepository<Admin_users,String>,
CustomAdminUsersRepository {

boolean existsByEmailAddress(String email);

}
</code>```

and this is my service

```<code>@Service
public class AdminUsersServiceImpl implements AdminUsersService {

@Autowired
AdminUsersRepository adminUsersRepository;

@JaversAuditable
@Override
public Admin_users updateAdminUser(Admin_users payload, String id) {
    if(!adminUsersRepository.existsById(id)){
        throw new InvalidException("Record Not Found");
    }

    adminUsersRepository.save(payload);
    return null;

}
</code>```

and this is the stacktrace

```<code>org.javers.common.exception.JaversException: COMMITTING_TOP_LEVEL_VALUES_NOT_SUPPORTED: Committing top-level ValueTypes like 'String' is not supported. You can commit only Entity or ValueObject instance.
at org.javers.core.JaversCore.assertJaversTypeNotValueTypeOrPrimitiveType(JaversCore.java:97) ~[javers-core-5.9.1.jar:na]
at org.javers.core.JaversCore.commit(JaversCore.java:81) ~[javers-core-5.9.1.jar:na]
at org.javers.spring.auditable.aspect.JaversCommitAdvice.commitObject(JaversCommitAdvice.java:81) ~[javers-spring-5.9.1.jar:na]
at org.javers.spring.auditable.aspect.JaversCommitAdvice.commitSaveMethodArguments(JaversCommitAdvice.java:54) ~[javers-spring-5.9.1.jar:na]
at org.javers.spring.auditable.aspect.JaversAuditableAspect.commitAdvice(JaversAuditableAspect.java:45) ~[javers-spring-5.9.1.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:626) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.aspectj.AspectJAfterReturningAdvice.afterReturning(AspectJAfterReturningAdvice.java:66) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:56) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at com.inventa.InventaService.Service.AdminUsersServiceImpl$$EnhancerBySpringCGLIB$$1d3b2d1b.updateAdminUser(<generated>) ~[classes/:na]
at com.inventa.InventaService.Controller.AdminUsersController.updateAdminUser(AdminUsersController.java:51) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:920) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:663) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at com.inventa.InventaService.Security.JwtAuthorizationFilter.doFilterInternal(JwtAuthorizationFilter.java:40) ~[classes/:na]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.30.jar:9.0.30]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.30.jar:9.0.30]
</code>```

Can you please let me know what is the problem, I am stuck here and cannot figure out the way. Thank you in advance

答: Javers is a kind of object database. The problem is that you are not committing objects but primitives - String. How do you want to track changes on a detached String? How do you want to load this String from a repository? It just not make any sense.

Body:
I am using javers in my spring boot with Mongodb, when updating or deleting I get the error COMMITTING_TOP_LEVEL_VALUES_NOT_SUPPORTED:Committing top-level ValueTypes like 'String' is not supported. You can commit only Entity or ValueObject instance.

this is my document class for mongodb

@Document("admin_users")
public class Admin_users {

@Id
private ObjectId _id;

@Indexed(unique = true)
private String userName;

private String password;
@CreatedDate
private Date dateCreated;
@LastModifiedDate
private Date dateModified;

@Indexed(unique = true)
private String emailAddress;

private String firstName;
private String lastName;
@Version
private Long version;

this is my repository

@JaversSpringDataAuditable
@Repository
public interface AdminUsersRepository extends MongoRepository<Admin_users,String>,
CustomAdminUsersRepository {

boolean existsByEmailAddress(String email);

}

and this is my service

@Service
public class AdminUsersServiceImpl implements AdminUsersService {

@Autowired
AdminUsersRepository adminUsersRepository;

@JaversAuditable
@Override
public Admin_users updateAdminUser(Admin_users payload, String id) {
    if(!adminUsersRepository.existsById(id)){
        throw new InvalidException("Record Not Found");
    }

    adminUsersRepository.save(payload);
    return null;

}

and this is the stacktrace

org.javers.common.exception.JaversException: COMMITTING_TOP_LEVEL_VALUES_NOT_SUPPORTED: Committing top-level ValueTypes like 'String' is not supported. You can commit only Entity or ValueObject instance.
at org.javers.core.JaversCore.assertJaversTypeNotValueTypeOrPrimitiveType(JaversCore.java:97) ~[javers-core-5.9.1.jar:na]
at org.javers.core.JaversCore.commit(JaversCore.java:81) ~[javers-core-5.9.1.jar:na]
at org.javers.spring.auditable.aspect.JaversCommitAdvice.commitObject(JaversCommitAdvice.java:81) ~[javers-spring-5.9.1.jar:na]
at org.javers.spring.auditable.aspect.JaversCommitAdvice.commitSaveMethodArguments(JaversCommitAdvice.java:54) ~[javers-spring-5.9.1.jar:na]
at org.javers.spring.auditable.aspect.JaversAuditableAspect.commitAdvice(JaversAuditableAspect.java:45) ~[javers-spring-5.9.1.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:626) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.aspectj.AspectJAfterReturningAdvice.afterReturning(AspectJAfterReturningAdvice.java:66) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:56) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:747) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:689) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at com.inventa.InventaService.Service.AdminUsersServiceImpl$$EnhancerBySpringCGLIB$$1d3b2d1b.updateAdminUser(<generated>) ~[classes/:na]
at com.inventa.InventaService.Controller.AdminUsersController.updateAdminUser(AdminUsersController.java:51) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_102]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_102]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_102]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_102]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:888) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:793) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:920) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:663) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:126) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:90) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:118) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:158) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at com.inventa.InventaService.Security.JwtAuthorizationFilter.doFilterInternal(JwtAuthorizationFilter.java:40) ~[classes/:na]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:92) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:77) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) ~[spring-security-web-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1598) [tomcat-embed-core-9.0.30.jar:9.0.30]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.30.jar:9.0.30]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_102]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_102]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.30.jar:9.0.30]

Can you please let me know what is the problem, I am stuck here and cannot figure out the way. Thank you in advance


问:
Shortest method to pass arguments to argv pointer
I wrote three ways of passing arguments to a function that accepts argv argument.

The first method of using string literals is the shortest and works fine, but gives me a deprecated warning as my test harness is cpp based:

```<code>error: conversion
      from string literal to 'char *' is deprecated
      [-Werror,-Wc++11-compat-deprecated-writable-strings]
</code>```

The method using malloc works, though it's a tad bit longer.

The last method causes a seg fault. Can you help me figure out the mistake in the third method, where I create an array with predefined size and copy the contents? Why does it fail?

```<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TEST3

int console_tester(int argc, char *argv[])
{
    printf("argv: %s\n", argv[0]);
    return 0;
}

int main()
{

#ifdef TEST1
    // works, shortest, but gives compilation warnings
    char *test_cmd[2] = {"hello1", "hello2"};
    int result = console_tester(2, (char**)test_cmd);
#endif

    // works, verbose
#ifdef TEST2
    char *test_cmd[2];
    test_cmd[0] = malloc(10);
    test_cmd[1] = malloc(10);
    memset(test_cmd[0], 0, 10);
    memset(test_cmd[0], 1, 10);
    memcpy(test_cmd[0], "hello1", sizeof("hello1"));
    memcpy(test_cmd[1], "hello2", sizeof("hello2"));
    int result = console_tester(2, (char**)test_cmd);
    free(test_cmd[0]);
    free(test_cmd[1]);
#endif

    // crash and burn
#ifdef TEST3
    char test_cmd[2][10];
    memset(&test_cmd[0], 0, 10);
    memset(&test_cmd[1], 0, 10);
    memcpy(&test_cmd[0], "hello1", sizeof("hello1"));
    memcpy(&test_cmd[1], "hello2", sizeof("hello2"));
    int result = console_tester(2, (char**)test_cmd);
#endif

    return 0;
}

</code>```

答:
In the third example you're doing an invalid conversion:

```<code>char test_cmd[2][10];
memset(&test_cmd[0], 0, 10);
memset(&test_cmd[1], 0, 10);
memcpy(&test_cmd[0], "hello1", sizeof("hello1"));
memcpy(&test_cmd[1], "hello2", sizeof("hello2"));

int result = console_tester(2, (char**)test_cmd);
</code>```

This produces a compiler warning for me when I strip off the (char**) brute-force casting:

```<code>warning: incompatible pointer types passing 'char (*)[10]' to parameter of type 'char **' [-Wincompatible-pointer-types]
</code>```

Which really should be an error. You can't switch those arbitrarily. You don't have the right kind of structure to pass in, so you must convert it to the correct structure first.

The other two examples both use char** properly so they're fine.

This is why turning on all warnings your compiler has to offer can help narrow down problems quickly. C, and by extension C++, really does not care if you're asking to do something invalid, it'll do it if told to do it, and then crash or act really strange because of it.

Body:
I wrote three ways of passing arguments to a function that accepts argv argument.

The first method of using string literals is the shortest and works fine, but gives me a deprecated warning as my test harness is cpp based:

error: conversion
      from string literal to 'char *' is deprecated
      [-Werror,-Wc++11-compat-deprecated-writable-strings]

The method using malloc works, though it's a tad bit longer.

The last method causes a seg fault. Can you help me figure out the mistake in the third method, where I create an array with predefined size and copy the contents? Why does it fail?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TEST3

int console_tester(int argc, char *argv[])
{
    printf("argv: %s\n", argv[0]);
    return 0;
}

int main()
{

#ifdef TEST1
    // works, shortest, but gives compilation warnings
    char *test_cmd[2] = {"hello1", "hello2"};
    int result = console_tester(2, (char**)test_cmd);
#endif

    // works, verbose
#ifdef TEST2
    char *test_cmd[2];
    test_cmd[0] = malloc(10);
    test_cmd[1] = malloc(10);
    memset(test_cmd[0], 0, 10);
    memset(test_cmd[0], 1, 10);
    memcpy(test_cmd[0], "hello1", sizeof("hello1"));
    memcpy(test_cmd[1], "hello2", sizeof("hello2"));
    int result = console_tester(2, (char**)test_cmd);
    free(test_cmd[0]);
    free(test_cmd[1]);
#endif

    // crash and burn
#ifdef TEST3
    char test_cmd[2][10];
    memset(&test_cmd[0], 0, 10);
    memset(&test_cmd[1], 0, 10);
    memcpy(&test_cmd[0], "hello1", sizeof("hello1"));
    memcpy(&test_cmd[1], "hello2", sizeof("hello2"));
    int result = console_tester(2, (char**)test_cmd);
#endif

    return 0;
}

Body:
In the third example you're doing an invalid conversion:

char test_cmd[2][10];
memset(&test_cmd[0], 0, 10);
memset(&test_cmd[1], 0, 10);
memcpy(&test_cmd[0], "hello1", sizeof("hello1"));
memcpy(&test_cmd[1], "hello2", sizeof("hello2"));

int result = console_tester(2, (char**)test_cmd);

This produces a compiler warning for me when I strip off the (char**) brute-force casting:

warning: incompatible pointer types passing 'char (*)[10]' to parameter of type 'char **' [-Wincompatible-pointer-types]

Which really should be an error. You can't switch those arbitrarily. You don't have the right kind of structure to pass in, so you must convert it to the correct structure first.

The other two examples both use char** properly so they're fine.

This is why turning on all warnings your compiler has to offer can help narrow down problems quickly. C, and by extension C++, really does not care if you're asking to do something invalid, it'll do it if told to do it, and then crash or act really strange because of it.


问:
ucwords but ignore words what are in BLOCK capitals?
I was wondering how to format the strings below to uppercase first letter of words but ingore words that are in uppercase already.

Examples

```<code>ABcd Efg = Abcd Efg
abcd EFG = Abcd EFG
</code>```

Could someone please give an example if it is possible.

Thanks

答:
```<code>$string = "abcd DefGH IJK";
$arr = explode( " ", $string );
foreach( $arr as &$word )
  if( $word != strtoupper($word ) )
    $word = ucfirst( strtolower( $word ) );
$string = implode( " ", $arr );
echo $string;
</code>```

Result: Abcd Defgh IJK

Body:
I was wondering how to format the strings below to uppercase first letter of words but ingore words that are in uppercase already.

Examples

ABcd Efg = Abcd Efg
abcd EFG = Abcd EFG

Could someone please give an example if it is possible.

Thanks

Body:
$string = "abcd DefGH IJK";
$arr = explode( " ", $string );
foreach( $arr as &$word )
  if( $word != strtoupper($word ) )
    $word = ucfirst( strtolower( $word ) );
$string = implode( " ", $arr );
echo $string;

Result: Abcd Defgh IJK


问:
Maven won't run JUnit5 tests
(BTW: Yes, I am including the Maven surefire plugin in my pom.)

I can't persuade Maven to run my JUnit5 tests.

I am using the Maven surefire plugin version 2.22

I tried downgrading the surefire plugin to 2.19

I'm using the same dependencies and plugins as another project which runs fine

If I import the project into eclipse, eclipse finds and executes the tests

The class file for the test, app.AppTest.class, is in directory target\test-classes\app

I don't get any error messages from Maven; it just says "Tests run: 0, Failures: 0, Errors: 0, Skipped: 0"

I am including the contents of my pom, below. Can anyone tell me what I'm doing wrong? Thanks for the help.

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>uw.syp.java</groupId>
  <artifactId>Temp1</artifactId>
  <packaging>jar</packaging>
  <version>01</version>
  <name>Temp1</name>
  <url>http://maven.apache.org</url>

    <properties>
       <developer>JesseJW</developer>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.3.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.3.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArgs>
                        <arg>-Xlint:all</arg>
                        <arg>-Xlint:-serial</arg>
                    </compilerArgs>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

As requested: source code including imports:
    package app;

```<code>import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

import java.net.URL;
import javax.swing.JOptionPane;

class AppTest
{
    void test()
    {
        System.out.println( "*************" );
        URL resURL  =  getClass().getClassLoader().getResource( "ResFile.txt" );
        System.out.println( resURL );
        assertNotNull( resURL );
        if ( resURL != null )
        {
            System.out.println( resURL.getPath() );
        }
    }
}
</code>```

答:
Parameters used by Surefire plugin (since 2.2) and worth double checking taking into account the project directory structure:

testSourceDirectory: the test source directory containing test class sources.
Default value is: ${project.build.testSourceDirectory} (default: src/test/java).

classesDirectory (for generated classes being tested).
Default value is: ${project.build.outputDirectory} (default: target/classes folder).

To change the defaults in pom.xml:

```<code><build>
    <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
</code>```

->

```<code><build>
    <testSourceDirectory>${project.basedir}/myPath</testSourceDirectory>
</code>```

http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html

Title: Maven won't run JUnit5 tests

Body:
(BTW: Yes, I am including the Maven surefire plugin in my pom.)

I can't persuade Maven to run my JUnit5 tests.

I am using the Maven surefire plugin version 2.22

I tried downgrading the surefire plugin to 2.19

I'm using the same dependencies and plugins as another project which runs fine

If I import the project into eclipse, eclipse finds and executes the tests

The class file for the test, app.AppTest.class, is in directory target\test-classes\app

I don't get any error messages from Maven; it just says "Tests run: 0, Failures: 0, Errors: 0, Skipped: 0"

I am including the contents of my pom, below. Can anyone tell me what I'm doing wrong? Thanks for the help.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>uw.syp.java</groupId>
  <artifactId>Temp1</artifactId>
  <packaging>jar</packaging>
  <version>01</version>
  <name>Temp1</name>
  <url>http://maven.apache.org</url>

    <properties>
       <developer>JesseJW</developer>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.3.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.3.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArgs>
                        <arg>-Xlint:all</arg>
                        <arg>-Xlint:-serial</arg>
                    </compilerArgs>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
        </plugins>
    </build>
</project>

As requested: source code including imports:
    package app;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.Test;

import java.net.URL;
import javax.swing.JOptionPane;

class AppTest
{
    void test()
    {
        System.out.println( "*************" );
        URL resURL  =  getClass().getClassLoader().getResource( "ResFile.txt" );
        System.out.println( resURL );
        assertNotNull( resURL );
        if ( resURL != null )
        {
            System.out.println( resURL.getPath() );
        }
    }
}

Body:
Parameters used by Surefire plugin (since 2.2) and worth double checking taking into account the project directory structure:

testSourceDirectory: the test source directory containing test class sources.
Default value is: ${project.build.testSourceDirectory} (default: src/test/java).

classesDirectory (for generated classes being tested).
Default value is: ${project.build.outputDirectory} (default: target/classes folder).

To change the defaults in pom.xml:

<build>
    <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>

->

<build>
    <testSourceDirectory>${project.basedir}/myPath</testSourceDirectory>

http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html


问:
How do I create a header style which spans from left most end to right end of the screen irrespective of screensize?
I want to Stretch this BLUE BAR, from one end of the screen to the other end. Now it is stretching 980px. Depending upon the screen size it should span itself from one end to the other end.

If I increase 980px, allignment will change. How to make the bar responsive ?

What CSS should I use ?

html {
  height: 100%;
  width: 100%;
}

body {
  height: 980px;
  width: 100%;
  margin: 0;
  padding: 0;
}

header {
  width: 980px;
  height: 40px;
  margin: 0 0 10px 0;
  padding: 0;
  background: #0B61A5;
  color: white;
}

navigation {
  width: 980px;
  margin: 0;
  padding: 0;
  text-align: center;
}

navigation ul {
  width: 980px;
  list-style: none;
  padding: 0;
  margin: 0;
}

navigation ul li {
  display: inline;
  margin-right: 1em;
}

footer {
  width: 940px;
  height: 20px;
  margin: 0 0 10px 0;
  padding: 10px 20px;
  background: #0B61A5;
  color: white;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code>
<html>
 <body>

  <header>
   <h1>OEMS User Area</h1>
  </header>

  <navigation>
   <ul>
    <li>User: </li>
    <li> Home </li>
    <li> Logout </li>
   </ul>
  </navigation>

  <footer> O.E.M.S </footer>

 </body>
</html></code>```

答:
You should use width:100% to stretch the header to full width for any device size.
If you want other design for the different device sizes, use media queries. Learn more about responsive design at https://www.w3schools.com/css/css_rwd_mediaqueries.asp</p>

```<code>body {
 height: 100%;
 width: 100%;
 margin: 0;
 padding: 0;
}

header {
 width: 100%;
 height: 40px;
 margin: 0 0 10px 0;
 padding: 0;
 background: #0B61A5;
 color: white;
}
</code>```

Body:
I want to Stretch this BLUE BAR, from one end of the screen to the other end. Now it is stretching 980px. Depending upon the screen size it should span itself from one end to the other end.

If I increase 980px, allignment will change. How to make the bar responsive ?

What CSS should I use ?

html {
  height: 100%;
  width: 100%;
}

body {
  height: 980px;
  width: 100%;
  margin: 0;
  padding: 0;
}

header {
  width: 980px;
  height: 40px;
  margin: 0 0 10px 0;
  padding: 0;
  background: #0B61A5;
  color: white;
}

navigation {
  width: 980px;
  margin: 0;
  padding: 0;
  text-align: center;
}

navigation ul {
  width: 980px;
  list-style: none;
  padding: 0;
  margin: 0;
}

navigation ul li {
  display: inline;
  margin-right: 1em;
}

footer {
  width: 940px;
  height: 20px;
  margin: 0 0 10px 0;
  padding: 10px 20px;
  background: #0B61A5;
  color: white;
}

OEMS User Area

  <navigation>

User:

 Home

 Logout

  </navigation>

   O.E.M.S

Body:
You should use width:100% to stretch the header to full width for any device size.
If you want other design for the different device sizes, use media queries. Learn more about responsive design at https://www.w3schools.com/css/css_rwd_mediaqueries.asp

body {
 height: 100%;
 width: 100%;
 margin: 0;
 padding: 0;
}

header {
 width: 100%;
 height: 40px;
 margin: 0 0 10px 0;
 padding: 0;
 background: #0B61A5;
 color: white;
}