问:
Javascript method document.querySelector alternative in VueJs for optimization
I need to optimize my code with all features of VueJs, so i've changed all the document.getElementById and document.querySelectorAll by using the ref in VueJs

So the only thing that i dont found an alternative is how to change :
document.querySelector with another code related to VueJs :

```<code>document.querySelector('.mc-layer__content').classList.add('disable-scroll')
</code>```

Is there any optimization related to this ?

Another important point, i can't use the ref here because the class is in the parent no in the component, so when i use this.$refs i can't see the parent element.

答:
Try with class binding:

new Vue({
  el: "#demo",
  data () {
    return {
      scroll: true
    }
  }
})```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.disable-scroll {
  color: red;
}</code>```

  <button @click="scroll = !scroll">switch</button>

    ssssss

```

Body:
I need to optimize my code with all features of VueJs, so i've changed all the document.getElementById and document.querySelectorAll by using the ref in VueJs

So the only thing that i dont found an alternative is how to change :
document.querySelector with another code related to VueJs :

document.querySelector('.mc-layer__content').classList.add('disable-scroll')

Is there any optimization related to this ?

Another important point, i can't use the ref here because the class is in the parent no in the component, so when i use this.$refs i can't see the parent element.

Body:
Try with class binding:

new Vue({
  el: "#demo",
  data () {
    return {
      scroll: true
    }
  }
})

.disable-scroll {
  color: red;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <button @click="scroll = !scroll">switch</button>
  <div class="mc-layer__content" :class="{'disable-scroll': scroll}">
    ssssss
  </div>
</div>


来源: stackexchange

问:
Map two classes in runtime using column mapping information provided in a JSON file
I have two Classes like this.

```<code>public class InputModel
{
    public int studentid { get; set; }
    public string studentname { get; set; }
    public string studentcity { get; set; }
}

public class OutputModel
{
    public int StudentIDColumn { get; set; }
    public string StudentNameColumn { get; set; }
    public string StudentCityColumn { get; set; }
}
</code>```

Now the requirement is like this:

I will receive an object of InputModel Class. From this, I need to create an object of OutputModel class.

It's simple if we use a library like AutoMapper. But the problem is, the Column-To-Column Mapping information will be supplied via a Json File like this:

```<code>{
  "studentid": "StudentIDColumn",
  "studentname": "StudentNameColumn",
  "studentcity": "StudentCityColumn"
}
</code>```

Based on the JSON mapping data, I need to Map the columns in runtime and generate the Output class object.

I tried to map the two classes using Automapper. But I am not sure how to do it in runtime using the JSON file.

```<code>var MapperConfig = new MapperConfiguration(c =>
            c.CreateMap<InputCSVModel, OutputIDMModel>()
            .ForMember(dest => dest.StudentIDColumn, act => act.MapFrom(src => src.studentid))
            .ForMember(dest => dest.StudentNameColumn, act => act.MapFrom(src => src.studentname))
            .ForMember(dest => dest.StudentCityColumn, act => act.MapFrom(src => src.studentcity))
            );

var mapper = new Mapper(MapperConfig);

OutputIDMModel outModel = mapper.Map<OutputIDMModel>(inputModel);
</code>```

I know that it's might be possible to do this with Reflection. But is there any better approach ?

答:
I was able to read the JSOn file and pass the strings in the automapper config like this.</p>
```<code>var MapperConfig = new MapperConfiguration(c =>
            c.CreateMap<InputModel, OutputModel>()
            .ForMember("StudentIDColumn", opt => opt.MapFrom("studentid"))
            .ForMember("StudentNameColumn", opt => opt.MapFrom("studentname"))
            .ForMember("StudentCityColumn", opt => opt.MapFrom("studentcity"))
            );
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have two Classes like this.

public class InputModel
{
    public int studentid { get; set; }
    public string studentname { get; set; }
    public string studentcity { get; set; }
}

public class OutputModel
{
    public int StudentIDColumn { get; set; }
    public string StudentNameColumn { get; set; }
    public string StudentCityColumn { get; set; }
}

Now the requirement is like this:

I will receive an object of InputModel Class. From this, I need to create an object of OutputModel class.

It's simple if we use a library like AutoMapper. But the problem is, the Column-To-Column Mapping information will be supplied via a Json File like this:

{
  "studentid": "StudentIDColumn",
  "studentname": "StudentNameColumn",
  "studentcity": "StudentCityColumn"
}

Based on the JSON mapping data, I need to Map the columns in runtime and generate the Output class object.

I tried to map the two classes using Automapper. But I am not sure how to do it in runtime using the JSON file.

var MapperConfig = new MapperConfiguration(c =>
            c.CreateMap<InputCSVModel, OutputIDMModel>()
            .ForMember(dest => dest.StudentIDColumn, act => act.MapFrom(src => src.studentid))
            .ForMember(dest => dest.StudentNameColumn, act => act.MapFrom(src => src.studentname))
            .ForMember(dest => dest.StudentCityColumn, act => act.MapFrom(src => src.studentcity))
            );

var mapper = new Mapper(MapperConfig);

OutputIDMModel outModel = mapper.Map<OutputIDMModel>(inputModel);

I know that it's might be possible to do this with Reflection. But is there any better approach ?

Body:
I was able to read the JSOn file and pass the strings in the automapper config like this.

var MapperConfig = new MapperConfiguration(c =>
            c.CreateMap<InputModel, OutputModel>()
            .ForMember("StudentIDColumn", opt => opt.MapFrom("studentid"))
            .ForMember("StudentNameColumn", opt => opt.MapFrom("studentname"))
            .ForMember("StudentCityColumn", opt => opt.MapFrom("studentcity"))
            );


问:
why Typo3 website v10 show empty sitemap xml in frontend
I'm using a Typo3 website version 10 and the sitemap is not working properly,
i can see the configuration in the typoscript object browser but in the front-end www.mydomain.ch/?type=1533906435 the xml file is blanc.
Frontend screenshot:

Typoscript object browser screenshot:

seo extension is installed.
the website is multilangage.

what can be missing so that i see the sitemap ?

答: i have solved the problem, i think it was the sourceopt extension installed have a bug, i have update it to the latest version, now i can see the xml sitemap working fine, thanks!</p>


问:
Using paramiko more than one time in a script
I am creating a script that uses different commands in different servers... To do it, I avoid to use tools like sshpass, and I try to do it by using paramiko (because with paramiko, I can handle exceptions and I can also exit the ssh session).

There are two machines that I must connect to, there are two different commands to use, etc.

The problem is, that I would like to not repeat the code I use twice, my code is something like:

```<code>    try:
        ssh_client = paramiko.SSHClient()
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        ssh_client.connect(args.ip, username=args.user,
                           port=port,
                           password=args.pwd,
                           timeout=connect_timeout,
                           allow_agent=False, look_for_keys=False)
    except Exception, e:
        print 'Failed to connect to %s: %s' % (args.ip, str(e))
        sys.exit(1)

    try:
        stdin, stdout, stderr = ssh_client.exec_command(command)
        commandStatus = stdout.channel.recv_exit_status()
        output = stdout.read()
        commandError = stderr.read()
    except Exception, e:
        print 'Failed to execute command "%s": %s' % (command, str(e))

    if commandError:
        print 'Command failed: %s' % (commandError)
        sys.exit(2)

    try:
        ssh_client = paramiko.SSHClient()
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        ssh_client.connect(args.ip2, username=args.user2,
                           port=port,
                           password=args.pwd2,
                           timeout=connect_timeout,
                           allow_agent=False, look_for_keys=False)
    except Exception, e:
        print 'Failed to connect to %s: %s' % (args.ip2, str(e))
        sys.exit(1)

    try:
        stdin, stdout, stderr = ssh_client.exec_command(command2)
        commandStatus = stdout.channel.recv_exit_status()
        output = stdout.read()
        commandError = stderr.read()
    except Exception, e:
        print 'Failed to execute command "%s": %s' % (command2, str(e))

    if commandError:
        print 'Command failed: %s' % (commandError)
        sys.exit(2)
</code>```

Is it possible to do it just using that code once?

答:
In general, the smallest element of code re-use is the function. So, make a function for creating the connection, for instance.

def connect(user, pass, hostname, port):
        ssh_client = paramiko.SSHClient()
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        ssh_client.connect(hostname, username=user,
                           port=port,
                           password=pass,
                           timeout=connect_timeout,
                           allow_agent=False, look_for_keys=False)
        return ssh_client

# then use the code, for instance
try:
        client_a = connect('admin', 'secret', 'myhost.com', 22)
        client_b = connect('notadmin', 'notsecret', 'otherhost.com', 22222)
except SomeException: # it's a bad idea to use plain Except
        print('message')
        sys.exit(1)
```

Body:
I am creating a script that uses different commands in different servers... To do it, I avoid to use tools like sshpass, and I try to do it by using paramiko (because with paramiko, I can handle exceptions and I can also exit the ssh session).

There are two machines that I must connect to, there are two different commands to use, etc.

The problem is, that I would like to not repeat the code I use twice, my code is something like:

    try:
        ssh_client = paramiko.SSHClient()
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        ssh_client.connect(args.ip, username=args.user,
                           port=port,
                           password=args.pwd,
                           timeout=connect_timeout,
                           allow_agent=False, look_for_keys=False)
    except Exception, e:
        print 'Failed to connect to %s: %s' % (args.ip, str(e))
        sys.exit(1)

    try:
        stdin, stdout, stderr = ssh_client.exec_command(command)
        commandStatus = stdout.channel.recv_exit_status()
        output = stdout.read()
        commandError = stderr.read()
    except Exception, e:
        print 'Failed to execute command "%s": %s' % (command, str(e))

    if commandError:
        print 'Command failed: %s' % (commandError)
        sys.exit(2)

    try:
        ssh_client = paramiko.SSHClient()
        ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        ssh_client.connect(args.ip2, username=args.user2,
                           port=port,
                           password=args.pwd2,
                           timeout=connect_timeout,
                           allow_agent=False, look_for_keys=False)
    except Exception, e:
        print 'Failed to connect to %s: %s' % (args.ip2, str(e))
        sys.exit(1)

    try:
        stdin, stdout, stderr = ssh_client.exec_command(command2)
        commandStatus = stdout.channel.recv_exit_status()
        output = stdout.read()
        commandError = stderr.read()
    except Exception, e:
        print 'Failed to execute command "%s": %s' % (command2, str(e))

    if commandError:
        print 'Command failed: %s' % (commandError)
        sys.exit(2)

Is it possible to do it just using that code once?


问:
Print details of an employee by entering the name of employee in Python
I am getting input of details of the employee from the user and then asking the user to enter the name of the employee, he wants to retrieve information of. I am saving all the entered data in a dictionary with employee name as its key and [employee_id, salary, address] as the values. Now whatever name I enter to retrieve the details, the output is always the details of the last entered employee.

```<code>    n = int(input('Enter the number of employee: '))
    employees = {}

    for i in range(n):
        name = input('Enter the name of the employee: ')
        emp_id = input("Enter employee Id: ")
        sal = int(input("Enter the employee salary: "))
        address = input('Enter the employee address: ')
        employees[name] = [emp_id, sal, address]

    while True:
        name = input('Enter employee name: ')
        info = employees.get(name, -1)
        if info == -1:
            print('Employee does not exist')
        else:
            print('Employee details are: \n Employee Id: ', emp_id, '\n Salary: ', sal, '\n Address: ', address)

        exit_choice = input('Do you want to exit [Yes|No]: ')
        if exit_choice == 'No' or exit_choice == 'no':
            break
</code>```

I want to get the output as the details of the employee whose name is entered. Please can you help me get out of this situation?

答:
a lots of bug in your code, the correct code will be,</p>
```<code>n = int(input('Enter the number of employee: '))
employees = {}

for i in range(n):
    name = input('Enter the name of the employee: ')
    emp_id = input("Enter employee Id: ")
    sal = int(input("Enter the employee salary: "))
    address = input('Enter the employee address: ')
    employees[name] = [emp_id, sal, address]

while True:
    name = input('Enter employee name: ')
    info = employees.get(name, -1)
    if info == -1:
        print('Employee does not exist')
    else:
        print(f'Employee details are: \n Employee Id: {info[0]}\n Salary: {info[1]}\n Address: info[2])')

    exit_choice = input('Do you want to exit [Yes|No]: ')
    if exit_choice == 'Yes' or exit_choice == 'yes':
        break
</code>```

Body:
I am getting input of details of the employee from the user and then asking the user to enter the name of the employee, he wants to retrieve information of. I am saving all the entered data in a dictionary with employee name as its key and [employee_id, salary, address] as the values. Now whatever name I enter to retrieve the details, the output is always the details of the last entered employee.

    n = int(input('Enter the number of employee: '))
    employees = {}

    for i in range(n):
        name = input('Enter the name of the employee: ')
        emp_id = input("Enter employee Id: ")
        sal = int(input("Enter the employee salary: "))
        address = input('Enter the employee address: ')
        employees[name] = [emp_id, sal, address]

    while True:
        name = input('Enter employee name: ')
        info = employees.get(name, -1)
        if info == -1:
            print('Employee does not exist')
        else:
            print('Employee details are: \n Employee Id: ', emp_id, '\n Salary: ', sal, '\n Address: ', address)

        exit_choice = input('Do you want to exit [Yes|No]: ')
        if exit_choice == 'No' or exit_choice == 'no':
            break

I want to get the output as the details of the employee whose name is entered. Please can you help me get out of this situation?

Body:
a lots of bug in your code, the correct code will be,

n = int(input('Enter the number of employee: '))
employees = {}

for i in range(n):
    name = input('Enter the name of the employee: ')
    emp_id = input("Enter employee Id: ")
    sal = int(input("Enter the employee salary: "))
    address = input('Enter the employee address: ')
    employees[name] = [emp_id, sal, address]

while True:
    name = input('Enter employee name: ')
    info = employees.get(name, -1)
    if info == -1:
        print('Employee does not exist')
    else:
        print(f'Employee details are: \n Employee Id: {info[0]}\n Salary: {info[1]}\n Address: info[2])')

    exit_choice = input('Do you want to exit [Yes|No]: ')
    if exit_choice == 'Yes' or exit_choice == 'yes':
        break


问:
MYSQL SubQuery with Max
I running into some time  issues using my simple select:

```<code>SELECT *
FROM ltowert
WHERE bat = 3
  AND id >= (SELECT id
             FROM ltowert
             WHERE bat = 3 AND ident = 'v0'
             ORDER BY id DESC
             LIMIT 1)
ORDER BY ident;
</code>```

It takes nearly 12 seconds (depending on the index, etc..)

If I run the subquery (0.00075 sec) and put the result in the statement:

```<code>SELECT *
FROM ltowert
WHERE bat = 3  AND id >= 20979399
ORDER BY ident;
</code>```

it runs in just 0.00095 sec, in addition: 0.0017 sec

So it seems, using the subquery avoid the Optimizer to use the index ?
How can I fix it and get quicker results ?

Thanks for any answers.

JR

答:
I test your proposal, but I run into a problem of understanding. Maybe, it's my issue:

Your idea works, but the result is wrong: Result is only 1 row, but I expect 11 rows.  I expect all row from l1, where id >= l2.id.

So I changed to:

```<code>SELECT *
FROM ltowert l1
INNER JOIN (
            SELECT id
            FROM ltowert
            WHERE bat = 3 AND ident = 'v0'
            order by id desc limit 1
            ) as l2 on l1.id>=l2.id
order by l1.ident;
</code>```

This return much rows. l1.bat = 0 which is not the request.
Change to:

A. ") as l2 on l1.id>=l2.id AND l1.bat = 3"

or

B. WHERE l1.bat = 3

runs into a timeout Error 2013.

What is my mistake ?

Additional, due to my 2 step tests, I do a test using a variable:

```<code>SELECT @ref_id:=id FROM  ltowert   WHERE bat = 3 AND ident = 'v0'  order by id desc limit 1;
SELECT * FROM ltowert l1 where bat = 3 AND l1.id >= @ref_id order by l1.ident;
</code>```

It is fast, and give the right results.
Is there a disadvantage to this usage?  (I know: 2 separate statements were not maintenance friendly)

Title: MYSQL SubQuery with Max

Body:
I running into some time  issues using my simple select:

SELECT *
FROM ltowert
WHERE bat = 3
  AND id >= (SELECT id
             FROM ltowert
             WHERE bat = 3 AND ident = 'v0'
             ORDER BY id DESC
             LIMIT 1)
ORDER BY ident;

It takes nearly 12 seconds (depending on the index, etc..)

If I run the subquery (0.00075 sec) and put the result in the statement:

SELECT *
FROM ltowert
WHERE bat = 3  AND id >= 20979399
ORDER BY ident;

it runs in just 0.00095 sec, in addition: 0.0017 sec

So it seems, using the subquery avoid the Optimizer to use the index ?
How can I fix it and get quicker results ?

Thanks for any answers.

JR

Body:
I test your proposal, but I run into a problem of understanding. Maybe, it's my issue:

Your idea works, but the result is wrong: Result is only 1 row, but I expect 11 rows.  I expect all row from l1, where id >= l2.id.

So I changed to:

SELECT *
FROM ltowert l1
INNER JOIN (
            SELECT id
            FROM ltowert
            WHERE bat = 3 AND ident = 'v0'
            order by id desc limit 1
            ) as l2 on l1.id>=l2.id
order by l1.ident;

This return much rows. l1.bat = 0 which is not the request.
Change to:

A. ") as l2 on l1.id>=l2.id AND l1.bat = 3"

or

B. WHERE l1.bat = 3

runs into a timeout Error 2013.

What is my mistake ?

Additional, due to my 2 step tests, I do a test using a variable:

SELECT @ref_id:=id FROM  ltowert   WHERE bat = 3 AND ident = 'v0'  order by id desc limit 1;
SELECT * FROM ltowert l1 where bat = 3 AND l1.id >= @ref_id order by l1.ident;

It is fast, and give the right results.
Is there a disadvantage to this usage?  (I know: 2 separate statements were not maintenance friendly)


问:
C++ check if entered value is unsigned integer
I'm trying to get unsigned integer from std::cin.

When enter a char or string my program stucks

```<code>#include <iostream>
#include <climits>

using namespace std;

int main()
{
    unsigned int number;
    do
    {
        cout << "Enter a unsigned number\t";
        cin >> number;

        if (0 < number && number < 65535 && std::cin.good())
        {
            cout << "It's a number";
            break;
        }
        cout << "Not a number";
    } while (true);
}
</code>```

How to do that ?

答:
The problem when you enter a non-numeric character is that extraction fails and that the character is still in the input stream. You need to remove it if extraction fails.

Another potential problem is your choice of type for the input, unsigned int. If that happens to be a 32 bit integer (which is very common) and the user enters -4294967295 for example, the extraction will succeed and the number will wrap around and become 1 - which is then accepted by the program. When using formatted extraction of numbers, it's safer to use a signed type (wider than needed for the target range) even if you want an unsigned number - and then check the range.

Example:

#include <cstdint>
#include <iostream>
#include <limits>

int main() {
    std::int32_t number; // enough to hold 0-65535 (and then some)

    do {
        std::cout << "Enter a number (1-65534)\t";

        // check that extraction succeeds and the number is in range [1,65534]:
        if(std::cin >> number && number > 0 && number < 65535) {
            std::cout << number << " is a valid number\n";
            break;
        } else {
            if(std::cin.eof()) {
                std::cout << "Bye bye\n";
                return 1;
            }
            std::cout << "Not a valid number\n";
            // clear error state
            std::cin.clear();

            // ignore the rest of the line
            std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        }
    } while(true);

    // if you want to store the number in a type suited for your range:
    auto final_number = static_cast<std::uint16_t>(number);
}
```

Body:
I'm trying to get unsigned integer from std::cin.

When enter a char or string my program stucks

#include <iostream>
#include <climits>

using namespace std;

int main()
{
    unsigned int number;
    do
    {
        cout << "Enter a unsigned number\t";
        cin >> number;

        if (0 < number && number < 65535 && std::cin.good())
        {
            cout << "It's a number";
            break;
        }
        cout << "Not a number";
    } while (true);
}

How to do that ?


问:
Kivy : AttributeError: 'Mylayout' object has no attribute 'hint'
I'm new to python and I am developing a US states flashcard with Kivy. The flashcard will shuffle the US states letter, the user will need to input the answer. When the user is not sure, he may click the Get Hint button, the flashcard will display a letter, the user may click for another letter until all letters are shown.

us_state_flaskcard_3.py file

        from kivy.app import App
        from kivy.lang import Builder
        from kivy.uix.widget import Widget
        from kivy.core.window import Window
        from kivy.uix.button import Button

        from random import choice
        from random import shuffle

        Builder.load_file('us_state_flashcard.kv')

        Window.size = (350, 600)

        class MainApp(App):
            title='US State Flashcard'
            def build(self):
                Window.clearcolor = (255/255, 255/255, 0, 1)
                return Mylayout()

            def shuffler(self):

                self.root.ids.entry_answer.text = ''
                self.root.ids.answer_label.text = ''
                self.root.ids.hint_label.text = ''

                global hint_count
                hint_count = 0

                states= ['Washington', 'Oregon','California','Ohio','Nebraska',
                    'Wisconsin', 'Daleware','Arkansas','Louisiana','California',
                    'Michigan','Florida', 'Taxes','Kectucky','Alabama','Alaska',
                    'Arizona','Colorado','Connecticut',' Georgia','Hawaii',
                    'Illinois','Indiana', 'Iowa','Maryland','Massachusetts',
                    'Rhode Island','New York']

                global word
                self.word = choice(states)
                self.root.ids.my_label.text = self.word
                break_apart_word = list(self.word)
                shuffle(break_apart_word)

                global shuffled_word
                shuffled_word = ''
                for letter in break_apart_word:
                    shuffled_word += letter

                self.root.ids.my_label.text = shuffled_word

            def answer(self):
                if self.word == self.root.ids.entry_answer.text :
                    self.root.ids.answer_label.text= "Correct!!"
                else:
                    self.root.ids.answer_label.text = "Incorrect!!"
            global hint_count
            hint_count = 0

            def hint(self, count):
                global hint_count
                hint_count = count

                word_length = len(self.word)

                if count < word_length:
                    self.root.ids.hint_label.text = f'{self.hint_label["text"]} {self.word[count]}'
                    hint_count +=1

            def on_start(self, **kwargs):
                self.shuffler()

        class Mylayout(Widget):
          def __init__(self, **kwargs):
                super(Mylayout, self).__init__(**kwargs)

                self.btn1 = Button(
                    text ='hint_button',
                    font_size ="20sp",
                    background_color =(1, 1, 1, 1),
                    color =(1, 1, 1, 1),
                    size =(200, 50),
                    pos =(80, 130)
                    )

                buttoncallback = lambda x : self.hint(hint_count)
                self.btn1.bind(on_press=buttoncallback)
                self.add_widget(self.btn1)

        if __name__ == '__main__':
            MainApp().run()
```
<p><strong>us_state_flaskcard_3.kv file</strong></p>
```        <MyLayout>

          FloatLayout:
                Label:
                    id: my_label
                    font_size: 25
                    text: 'abc'
                    pos_hint: {'x': 1.3, 'y':5}
                    size_hint: (1, 1)
                    color: 'black'

                TextInput:
                    id: entry_answer
                    multiline: False
                    font_size: 24
                    pos_hint: {'x': .8, 'y':4.5}
                    size_hint: (2, .4)
                    halign: "center"

                Button:
                    font_size: 20
                    text: "Answer"
                    on_press: app.answer()
                    pos_hint: {'x': .8, 'y':3.5 }
                    size_hint: (2, .5)

                Label:
                    id: answer_label
                    font_size: 25
                    text: ''
                    pos_hint: {'x': 0.8, 'y':2.8}
                    size_hint: (2, .5)
                    color: 'black'

                Button:
                    font_size: 20
                    text: "Pick Another Word"
                    on_press: app.shuffler()
                    pos_hint: {'x': .8, 'y':2 }
                    size_hint: (2, .5)

                Label:
                    id: hint_label
                    font_size: 20
                    text: 'Hint Label'
                    pos_hint: {'x': .8, 'y':1.5}
                    size_hint: (2, .5)
                    color: 'black'
```
<p>When I click the Get Hint Button, the error shown:</p>
<pre class="lang-py prettyprint-override"><code>     File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\base.py", line 342, in dispatch_input
         post_dispatch_input(*pop(0))
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\base.py", line 248, in post_dispatch_input
         listener.dispatch('on_motion', etype, me)
       File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\core\window\__init__.py", line 1412, in on_motion
         self.dispatch('on_touch_down', me)
       File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\core\window\__init__.py", line 1428, in on_touch_down
         if w.dispatch('on_touch_down', touch):
       File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\uix\widget.py", line 545, in on_touch_down
         if child.dispatch('on_touch_down', touch):
       File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\uix\behaviors\button.py", line 151, in on_touch_down
         self.dispatch('on_press')
       File "kivy\_event.pyx", line 705, in kivy._event.EventDispatcher.dispatch
       File "kivy\_event.pyx", line 1248, in kivy._event.EventObservers.dispatch
       File "kivy\_event.pyx", line 1172, in kivy._event.EventObservers._dispatch
       File "c:\Users\Kelvin Loh\Documents\kivyMD\us_state_flaskcard_3.py", line 115, in <lambda>
         buttoncallback = lambda x : self.hint(hint_count)
     AttributeError: 'Mylayout' object has no attribute 'hint'
</code>```

答:
You may be able to do it with get_running_app:

buttoncallback = lambda x : App.get_running_app().hint(hint_count)
```

Body:
I'm new to python and I am developing a US states flashcard with Kivy. The flashcard will shuffle the US states letter, the user will need to input the answer. When the user is not sure, he may click the Get Hint button, the flashcard will display a letter, the user may click for another letter until all letters are shown.

us_state_flaskcard_3.py file

        from kivy.app import App
        from kivy.lang import Builder
        from kivy.uix.widget import Widget
        from kivy.core.window import Window
        from kivy.uix.button import Button

        from random import choice
        from random import shuffle

        Builder.load_file('us_state_flashcard.kv')

        Window.size = (350, 600)

        class MainApp(App):
            title='US State Flashcard'
            def build(self):
                Window.clearcolor = (255/255, 255/255, 0, 1)
                return Mylayout()

            def shuffler(self):

                self.root.ids.entry_answer.text = ''
                self.root.ids.answer_label.text = ''
                self.root.ids.hint_label.text = ''

                global hint_count
                hint_count = 0

                states= ['Washington', 'Oregon','California','Ohio','Nebraska',
                    'Wisconsin', 'Daleware','Arkansas','Louisiana','California',
                    'Michigan','Florida', 'Taxes','Kectucky','Alabama','Alaska',
                    'Arizona','Colorado','Connecticut',' Georgia','Hawaii',
                    'Illinois','Indiana', 'Iowa','Maryland','Massachusetts',
                    'Rhode Island','New York']

                global word
                self.word = choice(states)
                self.root.ids.my_label.text = self.word
                break_apart_word = list(self.word)
                shuffle(break_apart_word)

                global shuffled_word
                shuffled_word = ''
                for letter in break_apart_word:
                    shuffled_word += letter

                self.root.ids.my_label.text = shuffled_word

            def answer(self):
                if self.word == self.root.ids.entry_answer.text :
                    self.root.ids.answer_label.text= "Correct!!"
                else:
                    self.root.ids.answer_label.text = "Incorrect!!"
            global hint_count
            hint_count = 0

            def hint(self, count):
                global hint_count
                hint_count = count

                word_length = len(self.word)

                if count < word_length:
                    self.root.ids.hint_label.text = f'{self.hint_label["text"]} {self.word[count]}'
                    hint_count +=1

            def on_start(self, **kwargs):
                self.shuffler()

        class Mylayout(Widget):
          def __init__(self, **kwargs):
                super(Mylayout, self).__init__(**kwargs)

                self.btn1 = Button(
                    text ='hint_button',
                    font_size ="20sp",
                    background_color =(1, 1, 1, 1),
                    color =(1, 1, 1, 1),
                    size =(200, 50),
                    pos =(80, 130)
                    )

                buttoncallback = lambda x : self.hint(hint_count)
                self.btn1.bind(on_press=buttoncallback)
                self.add_widget(self.btn1)

        if __name__ == '__main__':
            MainApp().run()

us_state_flaskcard_3.kv file

        <MyLayout>

          FloatLayout:
                Label:
                    id: my_label
                    font_size: 25
                    text: 'abc'
                    pos_hint: {'x': 1.3, 'y':5}
                    size_hint: (1, 1)
                    color: 'black'

                TextInput:
                    id: entry_answer
                    multiline: False
                    font_size: 24
                    pos_hint: {'x': .8, 'y':4.5}
                    size_hint: (2, .4)
                    halign: "center"

                Button:
                    font_size: 20
                    text: "Answer"
                    on_press: app.answer()
                    pos_hint: {'x': .8, 'y':3.5 }
                    size_hint: (2, .5)

                Label:
                    id: answer_label
                    font_size: 25
                    text: ''
                    pos_hint: {'x': 0.8, 'y':2.8}
                    size_hint: (2, .5)
                    color: 'black'

                Button:
                    font_size: 20
                    text: "Pick Another Word"
                    on_press: app.shuffler()
                    pos_hint: {'x': .8, 'y':2 }
                    size_hint: (2, .5)

                Label:
                    id: hint_label
                    font_size: 20
                    text: 'Hint Label'
                    pos_hint: {'x': .8, 'y':1.5}
                    size_hint: (2, .5)
                    color: 'black'

When I click the Get Hint Button, the error shown:

     File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\base.py", line 342, in dispatch_input
         post_dispatch_input(*pop(0))
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\base.py", line 248, in post_dispatch_input
         listener.dispatch('on_motion', etype, me)
       File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\core\window\__init__.py", line 1412, in on_motion
         self.dispatch('on_touch_down', me)
       File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\core\window\__init__.py", line 1428, in on_touch_down
         if w.dispatch('on_touch_down', touch):
       File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\uix\widget.py", line 545, in on_touch_down
         if child.dispatch('on_touch_down', touch):
       File "kivy\_event.pyx", line 709, in kivy._event.EventDispatcher.dispatch
       File "C:\Users\Kelvin Loh\Documents\kivyMD\kivy_venv\lib\site-packages\kivy\uix\behaviors\button.py", line 151, in on_touch_down
         self.dispatch('on_press')
       File "kivy\_event.pyx", line 705, in kivy._event.EventDispatcher.dispatch
       File "kivy\_event.pyx", line 1248, in kivy._event.EventObservers.dispatch
       File "kivy\_event.pyx", line 1172, in kivy._event.EventObservers._dispatch
       File "c:\Users\Kelvin Loh\Documents\kivyMD\us_state_flaskcard_3.py", line 115, in <lambda>
         buttoncallback = lambda x : self.hint(hint_count)
     AttributeError: 'Mylayout' object has no attribute 'hint'


问:
How to solve rails s error Gem::MissingSpecVersionError problem?
I am getting the error below when trying to run the application, so not sure how to solve it.

```<code>$ rails s
Traceback (most recent call last):
    5: from bin/rails:2:in `<main>'
    4: from bin/rails:2:in `load'
    3: from /Users/jolienai/Documents/github.com/railsfriends/friends/bin/spring:3:in `<top (required)>'
    2: from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
    1: from /Library/Ruby/Site/2.6.0/rubygems/dependency.rb:323:in `to_spec'
/Library/Ruby/Site/2.6.0/rubygems/dependency.rb:313:in `to_specs': Could not find 'bundler' (2.2.24) required by your /Users/jolienai/Documents/github.com/railsfriends/friends/Gemfile.lock. (Gem::MissingSpecVersionError)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.2.24`
Checked in 'GEM_PATH=/Users/jolienai/.gem/ruby/2.6.0:/Library/Ruby/Gems/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0' , execute `gem env` for more information
~/Documents/github.com/railsfriends/friends $

</code>```

I tried the command below but got another error

```<code>$ gem install bundler:2.2.24
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted @ apply2files - /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/CHANGELOG.md
</code>```
```<code>$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.2.24
  - RUBY VERSION: 3.0.2 (2021-07-07 patchlevel 107) [x86_64-darwin20]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/3.0.0
  - USER INSTALLATION DIRECTORY: /Users/jolienai/.gem/ruby/3.0.0
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/3.0.0/bin
  - SPEC CACHE DIRECTORY: /Users/jolienai/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/3.0.2/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-darwin-20
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/3.0.0
     - /Users/jolienai/.gem/ruby/3.0.0
     - /usr/local/Cellar/ruby/3.0.2/lib/ruby/gems/3.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/opt/ruby/bin
     - /Users/jolienai/google-cloud-sdk/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/go/bin
     - /usr/local/share/dotnet
     - ~/.dotnet/tools
     - /Library/Frameworks/Mono.framework/Versions/Current/Commands
     - /Users/jolienai/.rvm/bin
```
```

答:
Just had the same issue, I deleted the Gemfile.lock and installed the bundle.

```<code>rm Gemfile.lock
bundle install
</code>```

Body:
I am getting the error below when trying to run the application, so not sure how to solve it.

$ rails s
Traceback (most recent call last):
    5: from bin/rails:2:in `'
    4: from bin/rails:2:in `load'
    3: from /Users/jolienai/Documents/github.com/railsfriends/friends/bin/spring:3:in `<top (required)>'
    2: from /Library/Ruby/Site/2.6.0/rubygems/core_ext/kernel_gem.rb:62:in `gem'
    1: from /Library/Ruby/Site/2.6.0/rubygems/dependency.rb:323:in `to_spec'
/Library/Ruby/Site/2.6.0/rubygems/dependency.rb:313:in `to_specs': Could not find 'bundler' (2.2.24) required by your /Users/jolienai/Documents/github.com/railsfriends/friends/Gemfile.lock. (Gem::MissingSpecVersionError)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.2.24`
Checked in 'GEM_PATH=/Users/jolienai/.gem/ruby/2.6.0:/Library/Ruby/Gems/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0' , execute `gem env` for more information
~/Documents/github.com/railsfriends/friends $

I tried the command below but got another error

$ gem install bundler:2.2.24
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted @ apply2files - /usr/local/lib/ruby/gems/3.0.0/gems/bundler-2.2.24/CHANGELOG.md

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.2.24
  - RUBY VERSION: 3.0.2 (2021-07-07 patchlevel 107) [x86_64-darwin20]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/3.0.0
  - USER INSTALLATION DIRECTORY: /Users/jolienai/.gem/ruby/3.0.0
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/3.0.0/bin
  - SPEC CACHE DIRECTORY: /Users/jolienai/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/3.0.2/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-darwin-20
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/3.0.0
     - /Users/jolienai/.gem/ruby/3.0.0
     - /usr/local/Cellar/ruby/3.0.2/lib/ruby/gems/3.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/opt/ruby/bin
     - /Users/jolienai/google-cloud-sdk/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/go/bin
     - /usr/local/share/dotnet
     - ~/.dotnet/tools
     - /Library/Frameworks/Mono.framework/Versions/Current/Commands
     - /Users/jolienai/.rvm/bin
```

Body:
Just had the same issue, I deleted the Gemfile.lock and installed the bundle.

rm Gemfile.lock
bundle install


问:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile)
I am using Maven 3.0.5 and Spring Tool Source 3.2 with Maven plugin installed. When I try to do 'Run As---> Maven install', I am getting the following error:

```<code>[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring Social Twitter4J Sample 1.0.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven.plugins:maven-war-plugin:jar:2.1.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven.plugins:maven-install-plugin:jar:2.3.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ spring-social-twitter4j ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 15 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ spring-social-twitter4j ---
[WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Jun 21, 2013 2:14:32 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
WARNING: Error injecting: org.apache.maven.plugin.CompilerMojo
**java.lang.NoClassDefFoundError: org/codehaus/plexus/compiler/CompilerException**
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getDeclaredConstructors(Unknown Source)
    at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
    at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:98)
    at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:629)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:831)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:758)
    at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:255)
    at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:204)
    at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:954)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:987)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:950)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1000)
    at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
    at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
    at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:965)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
    at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:961)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
    at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.compiler.CompilerException
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    ... 54 more

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.749s
[INFO] Finished at: Fri Jun 21 02:14:32 IST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
**[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spring-social-twitter4j: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile: org/codehaus/plexus/compiler/CompilerException**
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/SS%20Computer/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar
[ERROR] urls[1] = file:/C:/Users/SS%20Computer/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.codehaus.plexus.compiler.CompilerException
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
</code>```

Please find below my pom.xml:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework.social.samples</groupId>
    <artifactId>spring-social-twitter4j</artifactId>
    <name>Spring Social Twitter4J Sample</name>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework.social-version>1.1.0.BUILD-SNAPSHOT</org.springframework.social-version>
        <org.springframework-version>3.2.1.RELEASE</org.springframework-version>
        <org.springframework.security-version>3.1.3.RELEASE</org.springframework.security-version>
        <org.slf4j-version>1.7.2</org.slf4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${org.springframework.security-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${org.springframework.security-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${org.springframework.security-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-core</artifactId>
            <version>${org.springframework.social-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-web</artifactId>
            <version>${org.springframework.social-version}</version>
        </dependency>

        <!-- Twitter4J -->
        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-core</artifactId>
            <version>2.2.3</version>
        </dependency>

        <!-- JSR 303 with Hibernate Validator -->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.159</version>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- CGLIB, only required and used for @Configuration usage -->
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.2</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl-api</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jstl-impl</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>org.springframework.maven.release</id>
            <name>Spring Maven Release Repository</name>
            <url>http://maven.springframework.org/release</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>
        <!-- For testing against latest Spring snapshots -->
        <repository>
            <id>org.springframework.maven.snapshot</id>
            <name>Spring Maven Snapshot Repository</name>
            <url>http://maven.springframework.org/snapshot</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
        <!-- For developing against latest Spring milestones -->
        <repository>
            <id>org.springframework.maven.milestone</id>
            <name>Spring Maven Milestone Repository</name>
            <url>http://maven.springframework.org/milestone</url>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>
    </repositories>
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <warName>spring-social-twitter4j</warName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.1</version>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

During maven install my goal is war:war to make WAR of my application.

答:
I have same problem and change fork tag in pom.xml from "true" to "false" and issue resolved.</p>
```<code><fork>true</fork>
</code>```

Body:
I am using Maven 3.0.5 and Spring Tool Source 3.2 with Maven plugin installed. When I try to do 'Run As---> Maven install', I am getting the following error:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Spring Social Twitter4J Sample 1.0.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven.plugins:maven-war-plugin:jar:2.1.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.maven.plugins:maven-install-plugin:jar:2.3.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ spring-social-twitter4j ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 15 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ spring-social-twitter4j ---
[WARNING] The POM for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Jun 21, 2013 2:14:32 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
WARNING: Error injecting: org.apache.maven.plugin.CompilerMojo
**java.lang.NoClassDefFoundError: org/codehaus/plexus/compiler/CompilerException**
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
    at java.lang.Class.getDeclaredConstructors(Unknown Source)
    at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
    at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:98)
    at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:629)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:831)
    at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:758)
    at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:255)
    at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:204)
    at com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:954)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:987)
    at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:950)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1000)
    at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52)
    at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:70)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
    at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
    at com.google.inject.internal.InjectorImpl$3$1.call(InjectorImpl.java:965)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
    at com.google.inject.internal.InjectorImpl$3.get(InjectorImpl.java:961)
    at com.google.inject.Scopes$1$1.get(Scopes.java:59)
    at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
    at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.compiler.CompilerException
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
    ... 54 more

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.749s
[INFO] Finished at: Fri Jun 21 02:14:32 IST 2013
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
**[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project spring-social-twitter4j: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile failed: A required class was missing while executing org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile: org/codehaus/plexus/compiler/CompilerException**
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-compiler-plugin:2.3.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/SS%20Computer/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-plugin-2.3.2.jar
[ERROR] urls[1] = file:/C:/Users/SS%20Computer/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------: org.codehaus.plexus.compiler.CompilerException
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

Please find below my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework.social.samples</groupId>
    <artifactId>spring-social-twitter4j</artifactId>
    <name>Spring Social Twitter4J Sample</name>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework.social-version>1.1.0.BUILD-SNAPSHOT</org.springframework.social-version>
        <org.springframework-version>3.2.1.RELEASE</org.springframework-version>
        <org.springframework.security-version>3.1.3.RELEASE</org.springframework.security-version>
        <org.slf4j-version>1.7.2</org.slf4j-version>
    </properties>
    <dependencies>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>

                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${org.springframework.security-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${org.springframework.security-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${org.springframework.security-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-core</artifactId>
            <version>${org.springframework.social-version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-web</artifactId>
            <version>${org.springframework.social-version}</version>
        </dependency>

        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-core</artifactId>
            <version>2.2.3</version>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.159</version>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.2</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp.jstl</groupId>
            <artifactId>jstl-api</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>jstl-impl</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>org.springframework.maven.release</id>
            <name>Spring Maven Release Repository</name>
            <url>http://maven.springframework.org/release</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>

        <repository>
            <id>org.springframework.maven.snapshot</id>
            <name>Spring Maven Snapshot Repository</name>
            <url>http://maven.springframework.org/snapshot</url>
            <releases><enabled>false</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>

        <repository>
            <id>org.springframework.maven.milestone</id>
            <name>Spring Maven Milestone Repository</name>
            <url>http://maven.springframework.org/milestone</url>
            <snapshots><enabled>false</enabled></snapshots>
        </repository>
    </repositories>
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <warName>spring-social-twitter4j</warName>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <version>1.1</version>
            </plugin>
        </plugins>
    </build>
</project>

During maven install my goal is war:war to make WAR of my application.

Body:
I have same problem and change fork tag in pom.xml from "true" to "false" and issue resolved.

<fork>true</fork>


问:
Typescript `Operator '+' cannot be applied to types` error occurs even though all cases are covered
Here is the code.

type Combinable = string | number;

function add(n: Combinable, b: Combinable) {
    if (typeof n === 'string'&& typeof b ==='string') {
        return n.toString() + b.toString();
    } else if (typeof n === 'string'&& typeof b ==='number') {
        return n.toString() + b.toString();
    } else if (typeof n === 'number'&& typeof b ==='string') {
        return n.toString() + b.toString();
    } else {
        // here raises error
        // Operator '+' cannot be applied to types 'Combinable' and 'Combinable'.ts(2365)
        return n + b;
    }
}

// But it works fine when I change "and" operator to "or" operator.
function add(n: Combinable, b: Combinable) {
    if (typeof n === 'string' || typeof b ==='string') {
        return n.toString() + b.toString();
    } else {
        return n + b;
    }
}

```

As you can see, I got the error on the last line n + m.

I thought it should work if I cover all cases, but the error still remains.

What am I missing here?

答:
type Param = string | number;

function add(a: Param, b: Param) {
  if (typeof a === 'number' && typeof b === 'number') {
    return a + b;
  }
  return a.toString() + b.toString();
}

add(1, '2');
add(1, 2);
add('1', '2');```

Body:
Here is the code.

type Combinable = string | number;

function add(n: Combinable, b: Combinable) {
    if (typeof n === 'string'&& typeof b ==='string') {
        return n.toString() + b.toString();
    } else if (typeof n === 'string'&& typeof b ==='number') {
        return n.toString() + b.toString();
    } else if (typeof n === 'number'&& typeof b ==='string') {
        return n.toString() + b.toString();
    } else {
        // here raises error
        // Operator '+' cannot be applied to types 'Combinable' and 'Combinable'.ts(2365)
        return n + b;
    }
}

// But it works fine when I change "and" operator to "or" operator.
function add(n: Combinable, b: Combinable) {
    if (typeof n === 'string' || typeof b ==='string') {
        return n.toString() + b.toString();
    } else {
        return n + b;
    }
}

As you can see, I got the error on the last line n + m.

I thought it should work if I cover all cases, but the error still remains.

What am I missing here?


问:
ORA-00979 : select distinct(concat column) not a group by expression
I am getting ORA-00979 with the following query:

```<code>SELECT
 DISTINCT ((colA || SUBSTR(colB, 1, 2))) AS colA
FROM myTable
WHERE colC='5678'
GROUP BY colA
</code>```

I have a table called myTable which has three columns (colA, colB and colC).

I want to have in my select result: the concatenation of column colA value and the two first values of column colB. Furthermore, I want to group by my result. However, I receive an ORA-00979 and not a group by expression error.

How can I solve this?

答:
You may repeat the entire expression in the GROUP BY clause as it appears in the SELECT:

SELECT DISTINCT colA || SUBSTR(colB, 1, 2) AS colA
FROM myTable
WHERE colC = '5678'
GROUP BY colA || SUBSTR(colB, 1, 2);
```

Oracle does not supporting grouping using aliases, or using 1, 2, etc. positional parameters.  And note that DISTINCT is not a SQL function.

Body:
I am getting ORA-00979 with the following query:

SELECT
 DISTINCT ((colA || SUBSTR(colB, 1, 2))) AS colA
FROM myTable
WHERE colC='5678'
GROUP BY colA

I have a table called myTable which has three columns (colA, colB and colC).

I want to have in my select result: the concatenation of column colA value and the two first values of column colB. Furthermore, I want to group by my result. However, I receive an ORA-00979 and not a group by expression error.

How can I solve this?

Body:
You may repeat the entire expression in the GROUP BY clause as it appears in the SELECT:

SELECT DISTINCT colA || SUBSTR(colB, 1, 2) AS colA
FROM myTable
WHERE colC = '5678'
GROUP BY colA || SUBSTR(colB, 1, 2);

Oracle does not supporting grouping using aliases, or using 1, 2, etc. positional parameters.  And note that DISTINCT is not a SQL function.


问:
Use a secure file from another azure pipeline library
I have the following yaml setup to download a secure file. The codesignfile.pfx is in a different project in Azure Devops. I have followed the instruction to allow the current's build service access by setting it as a user for that file. How do I reference the file from another pipeline's library in yaml? I think that is what I'm messing up.

I'm still getting the error:

The pipeline is not valid. Job Job: Step CodeSign input secureFile references secure file CodeSignfile.pfx which could not be found. The secure file does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz. Job Job: Step codesigning input secureFileId references secure file $(CodeSign.secureFilePath) which could not be found. The secure file does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz."<

```<code>
# Download a secure file to the agent machine
- task: DownloadSecureFile@1
  name: CodeSign # The name with which to reference the secure file's path on the agent, like $(mySecureFile.secureFilePath)
  displayName: 'Download Certificate'
  inputs:
    secureFile: 'codesignfile.pfx'
    #retryCount: 5 # Option
#sign our msi
- task: codesigning@2
  inputs:
    secureFileId: '$(CodeSign.secureFilePath)'
    signCertPassword: '$(Certificate Password)'
    files: '$(Build.SourcesDirecotry)/Product-Installer/Installer/bin/Release/*.exe'
    timeServer: 'http://timestamp.digicert.com'
    hashingAlgorithm: 'SHA256'
</code>```

答:
I'm afraid you can't use the secure file stored in another project in the pipeline.

Currently secure files are restricted to use at the Project level, we cannot use secure files across projects.

But your requirement is valuable. Here is a suggestion ticket with the same requirements: Azure DevOps Secure Files - Central store, shared between projects?

You can vote it and add comment in this suggestion ticket.

Body:
I have the following yaml setup to download a secure file. The codesignfile.pfx is in a different project in Azure Devops. I have followed the instruction to allow the current's build service access by setting it as a user for that file. How do I reference the file from another pipeline's library in yaml? I think that is what I'm messing up.

I'm still getting the error:

The pipeline is not valid. Job Job: Step CodeSign input secureFile references secure file CodeSignfile.pfx which could not be found. The secure file does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz. Job Job: Step codesigning input secureFileId references secure file $(CodeSign.secureFilePath) which could not be found. The secure file does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz."<

# Download a secure file to the agent machine
- task: DownloadSecureFile@1
  name: CodeSign # The name with which to reference the secure file's path on the agent, like $(mySecureFile.secureFilePath)
  displayName: 'Download Certificate'
  inputs:
    secureFile: 'codesignfile.pfx'
    #retryCount: 5 # Option
#sign our msi
- task: codesigning@2
  inputs:
    secureFileId: '$(CodeSign.secureFilePath)'
    signCertPassword: '$(Certificate Password)'
    files: '$(Build.SourcesDirecotry)/Product-Installer/Installer/bin/Release/*.exe'
    timeServer: 'http://timestamp.digicert.com'
    hashingAlgorithm: 'SHA256'


问:
finding id name of 5 most frequent value in a column in pandas
We have a data which has column name "birth_country"
i executed following code;

```<code>import pandas as pd
df=pd.read_csv("data.csv")
df['birth_country'].value_counts()[:5]
</code>```

output:

```<code>United States of America     259
United Kingdom               85
Germany                      61
France                       51
Sweden                       29
</code>```

I want my output to be look like;

```<code>United States of America
United Kingdom
Germany
France
Sweden
</code>```

How to do it?

Like;

```<code>df['birth_country'].value_counts().idxmax()
</code>```

gives output:

```<code>United States of America
</code>```

答:
For series by index values use:

```<code>pd.Series(df['birth_country'].value_counts()[:5].index)
</code>```

Body:
We have a data which has column name "birth_country"
i executed following code;

import pandas as pd
df=pd.read_csv("data.csv")
df['birth_country'].value_counts()[:5]

output:

United States of America     259
United Kingdom               85
Germany                      61
France                       51
Sweden                       29

I want my output to be look like;

United States of America
United Kingdom
Germany
France
Sweden

How to do it?

Like;

df['birth_country'].value_counts().idxmax()

gives output:

United States of America

Body:
For series by index values use:

pd.Series(df['birth_country'].value_counts()[:5].index)


问:
Prefer charset declaration in HTML meta tag or HTTP header?
I'm parsing a lot of sites. All works fine, I'm reading also charset declarations to convert encodings. Now I've a problem with http://celleheute.de/sonntagsfuhrung-3/.

The HTML meta tag says, that the content is encoded as ISO-8859-2, but the HTTP header says, it's UTF-8. And really, the content is UTF encoded, so when my parser tries to convert the content to ISO it will break some chars.

Now my question is, which declaration should I prefer? Should I ignore meta tags, when I can find the declaration in HTTP header or vice versa? What will most web browsers do?

答:
There's simply no answer to this. The author of the page has committed an error by giving conflicting information. Which one is correct may as well be decided by a coin toss.

In general, I'd prefer the HTTP header as the primary value. The meta tag is just meant as a fallback anyway. If you want to follow any logic at all, first try to decode the document using the charset specified in the HTTP header. If that clearly fails, because certain bytes are invalid in the given encoding, try again in the charset specified in the meta tag, if any. If that still fails, all bets are off.

If neither fails but the encodings conflict, either involve a human or try some statical analysis on the decoded text, which may tell you which is more likely to be correct.

ContentLicense: CC BY-SA 3.0


问:
Using LocalStorage with React?
From what I am experiencing so far, it doesn't seem like ReactJS updates with the state of localStorage. My code below.

```<code>var Frr = React.createClass({
getInitialState: function(){
return { lights: localStorage.getItem('state')}
},

switchoff: function(){
this.setState({lights: localStorage.setItem('state', 'off')});
},

switchon:function(){
this.setState({lights: localStorage.setItem('state', 'on')});
},

render:function(){
if (this.state.lights === 'on'){ return (
<div>
<p>The lights are ON</p>
<input type="submit" value="Switch" onClick={this.switchoff}/>
</div>
);}

if ( (this.state.lights === 'off')|| (!this.state.lights) ){ return (
<div>
<p>The lights are OFF</p>
<input type="submit" value="Switch" onClick={this.switchon}/>
</div>
);}

}
});
</code>```

Simple application. If the state of localstorage is off or empty, then render the view with the ON button. If localstorage is on, then render the view with the OFF button.

I want to be able to set this render based on the state of localStorage. I have tried doing the same thing using basic booleans, and it works as expected. However, when using localStorage, something doesn't appear to work.

I wouldn't be surprised if my logic is simply off.

EDIT: To explain, the button and the view don't act as they should. When the lights are off and there is nothing in Storage, the button adds ON to localStorage, but does not change the view. If I refresh the page, the page renders ON, and when I click on it the button works by turning it OFF. But it only works once, which leads me to believe there may be a problem with the OFF switch.

答:
```<code>const { data } = response;

const userData = data.user;
// Token Save to local Storage

const access = JSON.stringify(data.tokens);
const refresh = JSON.stringify(data.tokens);

localStorage.setItem('accessToken', access);
localStorage.setItem('refreshToken', refresh);
</code>```

Title: Using LocalStorage with React?

Body:
From what I am experiencing so far, it doesn't seem like ReactJS updates with the state of localStorage. My code below.

var Frr = React.createClass({
getInitialState: function(){
return { lights: localStorage.getItem('state')}
},

switchoff: function(){
this.setState({lights: localStorage.setItem('state', 'off')});
},

switchon:function(){
this.setState({lights: localStorage.setItem('state', 'on')});
},

render:function(){
if (this.state.lights === 'on'){ return (

The lights are ON

<input type="submit" value="Switch" onClick={this.switchoff}/>

);}

if ( (this.state.lights === 'off')|| (!this.state.lights) ){ return (

The lights are OFF

<input type="submit" value="Switch" onClick={this.switchon}/>

);}

}
});

Simple application. If the state of localstorage is off or empty, then render the view with the ON button. If localstorage is on, then render the view with the OFF button.

I want to be able to set this render based on the state of localStorage. I have tried doing the same thing using basic booleans, and it works as expected. However, when using localStorage, something doesn't appear to work.

I wouldn't be surprised if my logic is simply off.

EDIT: To explain, the button and the view don't act as they should. When the lights are off and there is nothing in Storage, the button adds ON to localStorage, but does not change the view. If I refresh the page, the page renders ON, and when I click on it the button works by turning it OFF. But it only works once, which leads me to believe there may be a problem with the OFF switch.


问:
Unable to log egress traffic HTTP requests with the istio-proxy
I am following this guide.

Ingress requests are getting logged. Egress traffic control is working as expected, except I am unable to log egress HTTP requests. What is missing?

apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
  name: myapp
spec:
  workloadSelector:
    labels:
      app: myapp

  outboundTrafficPolicy:
    mode: REGISTRY_ONLY

  egress:
    - hosts:
        - default/*.example.com
```
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: example

spec:
  location: MESH_EXTERNAL
  resolution: NONE
  hosts:
    - '*.example.com'

  ports:
    - name: https
      protocol: TLS
      number: 443
</code>```

apiVersion: telemetry.istio.io/v1alpha1
kind: Telemetry
metadata:
  name: mesh-default
  namespace: istio-system
spec:
  accessLogging:
    - providers:
        - name: envoy

```

Kubernetes 1.22.2 Istio 1.11.4

答:
For ingress traffic logging I am using EnvoyFilter to set log format and it is working without any additional configuration. In the egress case, I had to set accessLogFile: /dev/stdout.

apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
  name: config
  namespace: istio-system
spec:
  profile: default
  meshConfig:
    accessLogFile: /dev/stdout
```

Body:
I am following this guide.

Ingress requests are getting logged. Egress traffic control is working as expected, except I am unable to log egress HTTP requests. What is missing?

apiVersion: networking.istio.io/v1beta1
kind: Sidecar
metadata:
  name: myapp
spec:
  workloadSelector:
    labels:
      app: myapp

  outboundTrafficPolicy:
    mode: REGISTRY_ONLY

  egress:
    - hosts:
        - default/*.example.com

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: example

spec:
  location: MESH_EXTERNAL
  resolution: NONE
  hosts:
    - '*.example.com'

  ports:
    - name: https
      protocol: TLS
      number: 443

apiVersion: telemetry.istio.io/v1alpha1
kind: Telemetry
metadata:
  name: mesh-default
  namespace: istio-system
spec:
  accessLogging:
    - providers:
        - name: envoy

Kubernetes 1.22.2 Istio 1.11.4


问:
Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Hosting.Server.IServer Lifetime: Singleton

Failed to compare two elements in the array.
Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Hosting.Server.IServer Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl': Failed to compare two elements in the array.
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Hosting.Server.IServer Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl': Failed to compare two elements in the array.)'

I'm working on a dot net core project where I got these exceptions.
the code is

```<code>services.AddEthereumWallet();

services.AddRippleRegistration();

services.AddALTCoinRegisteration();

services.AddWHCRegisteration();

services.AddSingleton<DapperContext>();

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

services.AddScoped<IGroupRepository, GroupRepository>();

services.AddScoped<IGroupUserRepository, GroupUserRepository>();

services.AddScoped<IMeetingRespository, MeetingRepository>();

services.AddScoped<IMeetingUserRespository, MeetingUserRepository>();

services.AddScoped<IDeviceRepository, DeviceRepository>();

services.AddScoped<ITranslationRepository, TranslationRepository>();

services.AddScoped<IUserActivityRepository, UserActivityRepository>();

services.AddScoped<IUserInfoRepository, UserInfoRepository>();

services.AddScoped<ICallRepository, CallRepository>();

services.AddScoped<ILoginRepository, LoginRepository>();

services.AddScoped<IChatRepository, ChatRepository>();

services.AddScoped<IContactRepository, ContactRepository>();

services.AddScoped<IAccountRepository, AccountRepository>();

services.AddScoped<IWalletRepository, WalletRepository>();

services.AddScoped<IGroupChatRepository, GroupChatRepository>();

services.AddControllers();

</code>```

I search a lot but didn't get any solution.

答: Update your NuGet package according to your Framework. You are using Bittrex library and Ethereum Node in your Project Some Nuget Packages are Conflicting with your Solution Project.</p>

Body:
Failed to compare two elements in the array.
Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Hosting.Server.IServer Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl': Failed to compare two elements in the array.
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: Microsoft.AspNetCore.Hosting.Server.IServer Lifetime: Singleton ImplementationType: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl': Failed to compare two elements in the array.)'

I'm working on a dot net core project where I got these exceptions.
the code is

services.AddEthereumWallet();

services.AddRippleRegistration();

services.AddALTCoinRegisteration();

services.AddWHCRegisteration();

services.AddSingleton<DapperContext>();

services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

services.AddScoped<IGroupRepository, GroupRepository>();

services.AddScoped<IGroupUserRepository, GroupUserRepository>();

services.AddScoped<IMeetingRespository, MeetingRepository>();

services.AddScoped<IMeetingUserRespository, MeetingUserRepository>();

services.AddScoped<IDeviceRepository, DeviceRepository>();

services.AddScoped<ITranslationRepository, TranslationRepository>();

services.AddScoped<IUserActivityRepository, UserActivityRepository>();

services.AddScoped<IUserInfoRepository, UserInfoRepository>();

services.AddScoped<ICallRepository, CallRepository>();

services.AddScoped<ILoginRepository, LoginRepository>();

services.AddScoped<IChatRepository, ChatRepository>();

services.AddScoped<IContactRepository, ContactRepository>();

services.AddScoped<IAccountRepository, AccountRepository>();

services.AddScoped<IWalletRepository, WalletRepository>();

services.AddScoped<IGroupChatRepository, GroupChatRepository>();

services.AddControllers();

I search a lot but didn't get any solution.