问:
What programming language is most like natural language?
I got the idea for this question from numerous situations where I don't understand what the person is talking about and when others don't understand me.

So, a "smart" solution would be to speak a computer language. :)

I am interested how far a programming language can go to get near to (English) natural language. When I say near, I mean not just to use words and sentences, but to be able to "do" things a natural language can "do" and by "do" I mean that it can be used (in a very limited way) as a replacement for natural language.

I know that this is impossible (is it?) but I think that this can be interesting.

答:
gherkin is a domain specific language to
describe executable bdd-specifications. It is used among other by cucumber (ruby) and specflow (dotnet).

Example

```<code>    Feature: Browsing
        In order to see who's been on the site
        As a user
        I want to be able to view the list of posts

    Scenario: Navigation to homepage
        When I navigate to /Guestbook
        Then I should be on the guestbook page

    Scenario: Viewing existing entries
        Given I am on the guestbook page
        Then I should see a list of guestbook entries
            And guestbook entries have an author
            And guestbook entries have a posted date
            And guestbook entries have a comment

    Scenario: Most recent entries are displayed first
        Given we have the following existing entries
            | Name      | Comment      | Posted date       |
            | Mr. A     | I like A     | 2008-10-01 09:20  |
            | Mrs. B    | I like B     | 2010-03-05 02:15  |
            | Dr. C     | I like C     | 2010-02-20 12:21  |
          And I am on the guestbook page
        Then the guestbook entries includes the following, in this order
            | Name      | Comment      | Posted date       |
            | Mrs. B    | I like B     | 2010-03-05 02:15  |
            | Dr. C     | I like C     | 2010-02-20 12:21  |
            | Mr. A     | I like A     | 2008-10-01 09:20  |
</code>```

OwnerDisplayName: kliketa

Body:
gherkin is a domain specific language to
describe executable bdd-specifications. It is used among other by cucumber (ruby) and specflow (dotnet).

Example

    Feature: Browsing
        In order to see who's been on the site
        As a user
        I want to be able to view the list of posts

    Scenario: Navigation to homepage
        When I navigate to /Guestbook
        Then I should be on the guestbook page

    Scenario: Viewing existing entries
        Given I am on the guestbook page
        Then I should see a list of guestbook entries
            And guestbook entries have an author
            And guestbook entries have a posted date
            And guestbook entries have a comment

    Scenario: Most recent entries are displayed first
        Given we have the following existing entries
            | Name      | Comment      | Posted date       |
            | Mr. A     | I like A     | 2008-10-01 09:20  |
            | Mrs. B    | I like B     | 2010-03-05 02:15  |
            | Dr. C     | I like C     | 2010-02-20 12:21  |
          And I am on the guestbook page
        Then the guestbook entries includes the following, in this order
            | Name      | Comment      | Posted date       |
            | Mrs. B    | I like B     | 2010-03-05 02:15  |
            | Dr. C     | I like C     | 2010-02-20 12:21  |
            | Mr. A     | I like A     | 2008-10-01 09:20  |


来源: stackexchange

问:
What wrong with my Python code to check the triangular number?
```<code>def Triangular(n):
    arr = []
    for i in range(n):
        T = i*(i+1)/2
        arr.append(T)
    if n == any(arr):
        return True
    else:
        return False
</code>```

All test cases are in False. Please show me what I was wrong

答:
Try this lambda:

```<code>Triangular = lambda x: (0.5 * ((8 * x + 1) ** 0.5 - 1)).is_integer()
</code>```

Here's how it works:

Multiply n by 8 and subtract 1

Find the square root of that number

Subtract it by 1 and divide it by 2

Remove the decimal part of the number

If the resulting number is greater than 0, it is triangular

You can also use this lambda from this answer to check if the number is Triangular:

```<code>Triangular = lambda n:(8*n+1)**.5%1>0
</code>```

ContentLicense: CC BY-SA 3.0

Body:
def Triangular(n):
    arr = []
    for i in range(n):
        T = i*(i+1)/2
        arr.append(T)
    if n == any(arr):
        return True
    else:
        return False

All test cases are in False. Please show me what I was wrong

Body:
Try this lambda:

Triangular = lambda x: (0.5 * ((8 * x + 1) ** 0.5 - 1)).is_integer()

Here's how it works:

Multiply n by 8 and subtract 1

Find the square root of that number

Subtract it by 1 and divide it by 2

Remove the decimal part of the number

If the resulting number is greater than 0, it is triangular

You can also use this lambda from this answer to check if the number is Triangular:

Triangular = lambda n:(8*n+1)**.5%1>0

ContentLicense: CC BY-SA 4.0


问:
Send data to JS when PHP is told to do so
Here's an example. One user connects to the website and does some stuff. JS sends changes to PHP and it's processed. Say another user that connected at the same time needs to be notified of this change. So PHP somehow tells the second users browser through JS or something to change some HTML to the second user is aware of said changes. Is there a way I can do this? Or is it a no can do?</p>

答:
that would be done with Ajax or WEbSockets.
WebSocket works by opening a connection channel between the server and users.
you can find some websocket Examples Here:
http://www.websocket.org/demos.html</p>


问:
fitting with conditional in grouped data
Sorry for too long question but I'll try to be clear as possible about the problem.

I am trying to do fitting in different groups in data and trying to get fitting coefficients for each group.

I looked around but could not exactly the same problem but found some similar posts like below,

Conditional nls

Trying to fit data with R and nls on a function with a condition in it

But it seems that the fitting doesn't seem to care the conditional setting so I am getting the same fitting coeffs for different groups.(This is also the same case for my real data.)

basically, what try to do is use different set of fitting coefficients if gr==a fit that group else fit gr==b.

I am using nlsLM from minpack.lm package since I also need to set the starting values for fitting coefs.

Here is the code which I have tried:

```<code>library(minpack.lm)

set.seed(95)

df <- data.frame(gr=rep(seq(1,2),each=10),sub_gr=rep(rep(c("a","b"),each=5),2),
              y = rep(c(sort(runif(5,0,0.5),decreasing=TRUE), sort(runif(5,0,0.5),,decreasing=TRUE)),2),
              x = rep(c(seq(0.1,0.5,0.1)),4))
</code>```

#creating empty list to fill with fitting coefficients afterwards
based on @Hack-R solution
Error: Results are not data frames at positions:

```<code>empty_dat <- structure(list(x = numeric(0), y = numeric(0), gr = integer(0), sub_gr = character(0),
              pred_fit = numeric(0), k_a = numeric(0), k_b = numeric(0),
              t_a = numeric(0), t_b= numeric(0)), class = "data.frame")

#do the fitting in groups

for(x in unique(df$gr)){

  #trycatch to

  fit <- tryCatch(nlsLM(y~ifelse(sub_gr=='a', k_a*x+t_a, k_b*x+t_b),
                        data=df[df$gr==x,],start=c(k_a=0.3,k_b=0.4,t_a=0.1,t_b=0.2),

                        lower = c(0.05, 0.05, 0,0),
                        upper = c(1,1,1,1),
                        trace=T,na.action=na.omit, control = nls.lm.control(maxiter=100)),error=function(e) NULL)

  if(!("NULL" %in% class(fit))){
    pred_fit <- predict(fit, newdata =df$x)

    coefs_fit <- data.frame(k_a=coef(fit)[1],k_b=coef(fit)[2],t_a=coef(fit)[3], t_b=coef(fit)[4])

#filling empty_data with coefs and df's original values
        empty_dat <- rbind(empty_dat,data.frame(df[df$gr==x,],coefs_fit,pred_fit,row.names=NULL))
              }
            }
</code>```

empty_dat

```<code>  gr sub_gr          y   x  k_a  k_b       t_a       t_b  pred_fit
1   1      a 0.28792044 0.1 0.05 0.05 0.1343742 0.2156747 0.1393742
2   1      a 0.24443957 0.2 0.05 0.05 0.1343742 0.2156747 0.1443742
3   1      a 0.07585577 0.3 0.05 0.05 0.1343742 0.2156747 0.1493742
4   1      a 0.03522243 0.4 0.05 0.05 0.1343742 0.2156747 0.1543742
5   1      a 0.02654922 0.5 0.05 0.05 0.1343742 0.2156747 0.1593742
6   1      b 0.48498563 0.1 0.05 0.05 0.1343742 0.2156747 0.2206747
7   1      b 0.18702842 0.2 0.05 0.05 0.1343742 0.2156747 0.2256747
8   1      b 0.15186749 0.3 0.05 0.05 0.1343742 0.2156747 0.2306747
9   1      b 0.15003048 0.4 0.05 0.05 0.1343742 0.2156747 0.2356747
10  1      b 0.07638354 0.5 0.05 0.05 0.1343742 0.2156747 0.2406747
11  2      a 0.28792044 0.1 0.05 0.05 0.1343742 0.2156747 0.1393742
12  2      a 0.24443957 0.2 0.05 0.05 0.1343742 0.2156747 0.1443742
13  2      a 0.07585577 0.3 0.05 0.05 0.1343742 0.2156747 0.1493742
14  2      a 0.03522243 0.4 0.05 0.05 0.1343742 0.2156747 0.1543742
15  2      a 0.02654922 0.5 0.05 0.05 0.1343742 0.2156747 0.1593742
16  2      b 0.48498563 0.1 0.05 0.05 0.1343742 0.2156747 0.2206747
17  2      b 0.18702842 0.2 0.05 0.05 0.1343742 0.2156747 0.2256747
18  2      b 0.15186749 0.3 0.05 0.05 0.1343742 0.2156747 0.2306747
19  2      b 0.15003048 0.4 0.05 0.05 0.1343742 0.2156747 0.2356747
20  2      b 0.07638354 0.5 0.05 0.05 0.1343742 0.2156747 0.2406747
</code>```

as we can see clearly the coefficients k_a, k_b and t_a , t_b is identical for each gr and sub_gr.

If I want to plot the result and predicted values of fitting

fitting lines telling the different story:))

```<code>library(ggplot2)

ggplot(df, aes(x=x, y=y,col=sub_gr,shape=sub_gr)) +
  geom_point(size=6,alpha=0.8,stroke=1.4)  +
  theme_bw()+
  facet_wrap(~gr,scales='free')+
  scale_color_manual(values=c("blue","red"))+
  geom_line(data=empty_dat,aes(x=x,y=pred_fit,group=sub_gr,col=sub_gr))
</code>```

答:
Here's a possible solution. However, based on how you've set up the sample data, I run into the same problem you mentioned, that the models are the same for each group. That said, the training data is exactly the same for both groups, so I'm not surprised to get identical coefficients.

```<code>library(tidyverse)
library(broom)

# a function to build the model
makefit <- function(df) {
    tryCatch(nlsLM(y~ifelse(sub_gr=='a', k_a*x+t_a, k_b/x+t_b),
                        data=df,start=c(k_a=0.3,k_b=0.4,t_a=0.1,t_b=0.2),

                        lower = c(0.05, 0.05, 0,0),
                        upper = c(1,1,1,1),
                        trace=T,na.action=na.omit, control = nls.lm.control(maxiter=100)),error=function(e) NULL)
}

# a function to get the coefficients out of the model
myaugment <- function(fit) {
    data.frame(k_a=coef(fit)[1],k_b=coef(fit)[2],t_a=coef(fit)[3], t_b=coef(fit)[4])
}

dfprep <- df %>%
  group_by(gr) %>%
  # nest the other variables as a list col
  nest() %>%
  mutate(
       # build a model for each group
       model = map(data, makefit)
       # get the coeffients
     , modelaugment = map(model, myaugment)
  )

 # extract the results
results <- dfprep %>%
  # extract the original data
  unnest(data) %>%
  # join in the coefficent data
  left_join(dfprep %>% unnest(modelaugment), by = 'gr')
</code>```

Also, I wasn't sure where you were getting your new testing data set from since it wasn't included in your example, so I didn't include a way to get that. However, building that into the makeaugment() function should be pretty straightforward.

Body:
Sorry for too long question but I'll try to be clear as possible about the problem.

I am trying to do fitting in different groups in data and trying to get fitting coefficients for each group.

I looked around but could not exactly the same problem but found some similar posts like below,

Conditional nls

Trying to fit data with R and nls on a function with a condition in it

But it seems that the fitting doesn't seem to care the conditional setting so I am getting the same fitting coeffs for different groups.(This is also the same case for my real data.)

basically, what try to do is use different set of fitting coefficients if gr==a fit that group else fit gr==b.

I am using nlsLM from minpack.lm package since I also need to set the starting values for fitting coefs.

Here is the code which I have tried:

library(minpack.lm)

set.seed(95)

df <- data.frame(gr=rep(seq(1,2),each=10),sub_gr=rep(rep(c("a","b"),each=5),2),
              y = rep(c(sort(runif(5,0,0.5),decreasing=TRUE), sort(runif(5,0,0.5),,decreasing=TRUE)),2),
              x = rep(c(seq(0.1,0.5,0.1)),4))

#creating empty list to fill with fitting coefficients afterwards
based on @Hack-R solution
Error: Results are not data frames at positions:

empty_dat <- structure(list(x = numeric(0), y = numeric(0), gr = integer(0), sub_gr = character(0),
              pred_fit = numeric(0), k_a = numeric(0), k_b = numeric(0),
              t_a = numeric(0), t_b= numeric(0)), class = "data.frame")

#do the fitting in groups

for(x in unique(df$gr)){

  #trycatch to

  fit <- tryCatch(nlsLM(y~ifelse(sub_gr=='a', k_a*x+t_a, k_b*x+t_b),
                        data=df[df$gr==x,],start=c(k_a=0.3,k_b=0.4,t_a=0.1,t_b=0.2),

                        lower = c(0.05, 0.05, 0,0),
                        upper = c(1,1,1,1),
                        trace=T,na.action=na.omit, control = nls.lm.control(maxiter=100)),error=function(e) NULL)

  if(!("NULL" %in% class(fit))){
    pred_fit <- predict(fit, newdata =df$x)

    coefs_fit <- data.frame(k_a=coef(fit)[1],k_b=coef(fit)[2],t_a=coef(fit)[3], t_b=coef(fit)[4])

#filling empty_data with coefs and df's original values
        empty_dat <- rbind(empty_dat,data.frame(df[df$gr==x,],coefs_fit,pred_fit,row.names=NULL))
              }
            }

empty_dat

  gr sub_gr          y   x  k_a  k_b       t_a       t_b  pred_fit
1   1      a 0.28792044 0.1 0.05 0.05 0.1343742 0.2156747 0.1393742
2   1      a 0.24443957 0.2 0.05 0.05 0.1343742 0.2156747 0.1443742
3   1      a 0.07585577 0.3 0.05 0.05 0.1343742 0.2156747 0.1493742
4   1      a 0.03522243 0.4 0.05 0.05 0.1343742 0.2156747 0.1543742
5   1      a 0.02654922 0.5 0.05 0.05 0.1343742 0.2156747 0.1593742
6   1      b 0.48498563 0.1 0.05 0.05 0.1343742 0.2156747 0.2206747
7   1      b 0.18702842 0.2 0.05 0.05 0.1343742 0.2156747 0.2256747
8   1      b 0.15186749 0.3 0.05 0.05 0.1343742 0.2156747 0.2306747
9   1      b 0.15003048 0.4 0.05 0.05 0.1343742 0.2156747 0.2356747
10  1      b 0.07638354 0.5 0.05 0.05 0.1343742 0.2156747 0.2406747
11  2      a 0.28792044 0.1 0.05 0.05 0.1343742 0.2156747 0.1393742
12  2      a 0.24443957 0.2 0.05 0.05 0.1343742 0.2156747 0.1443742
13  2      a 0.07585577 0.3 0.05 0.05 0.1343742 0.2156747 0.1493742
14  2      a 0.03522243 0.4 0.05 0.05 0.1343742 0.2156747 0.1543742
15  2      a 0.02654922 0.5 0.05 0.05 0.1343742 0.2156747 0.1593742
16  2      b 0.48498563 0.1 0.05 0.05 0.1343742 0.2156747 0.2206747
17  2      b 0.18702842 0.2 0.05 0.05 0.1343742 0.2156747 0.2256747
18  2      b 0.15186749 0.3 0.05 0.05 0.1343742 0.2156747 0.2306747
19  2      b 0.15003048 0.4 0.05 0.05 0.1343742 0.2156747 0.2356747
20  2      b 0.07638354 0.5 0.05 0.05 0.1343742 0.2156747 0.2406747

as we can see clearly the coefficients k_a, k_b and t_a , t_b is identical for each gr and sub_gr.

If I want to plot the result and predicted values of fitting

fitting lines telling the different story:))

library(ggplot2)

ggplot(df, aes(x=x, y=y,col=sub_gr,shape=sub_gr)) +
  geom_point(size=6,alpha=0.8,stroke=1.4)  +
  theme_bw()+
  facet_wrap(~gr,scales='free')+
  scale_color_manual(values=c("blue","red"))+
  geom_line(data=empty_dat,aes(x=x,y=pred_fit,group=sub_gr,col=sub_gr))

Body:
Here's a possible solution. However, based on how you've set up the sample data, I run into the same problem you mentioned, that the models are the same for each group. That said, the training data is exactly the same for both groups, so I'm not surprised to get identical coefficients.

library(tidyverse)
library(broom)

# a function to build the model
makefit <- function(df) {
    tryCatch(nlsLM(y~ifelse(sub_gr=='a', k_a*x+t_a, k_b/x+t_b),
                        data=df,start=c(k_a=0.3,k_b=0.4,t_a=0.1,t_b=0.2),

                        lower = c(0.05, 0.05, 0,0),
                        upper = c(1,1,1,1),
                        trace=T,na.action=na.omit, control = nls.lm.control(maxiter=100)),error=function(e) NULL)
}

# a function to get the coefficients out of the model
myaugment <- function(fit) {
    data.frame(k_a=coef(fit)[1],k_b=coef(fit)[2],t_a=coef(fit)[3], t_b=coef(fit)[4])
}

dfprep <- df %>%
  group_by(gr) %>%
  # nest the other variables as a list col
  nest() %>%
  mutate(
       # build a model for each group
       model = map(data, makefit)
       # get the coeffients
     , modelaugment = map(model, myaugment)
  )

 # extract the results
results <- dfprep %>%
  # extract the original data
  unnest(data) %>%
  # join in the coefficent data
  left_join(dfprep %>% unnest(modelaugment), by = 'gr')

Also, I wasn't sure where you were getting your new testing data set from since it wasn't included in your example, so I didn't include a way to get that. However, building that into the makeaugment() function should be pretty straightforward.


问:
Find maximum value in each row or column of an Excel array
In Excel I have a named range that contains an array, for example like the array below.

```<code>0 0 0 7
0 0 6 5
0 5 3 2
4 3 2 1
</code>```

I'd like to find the maximum value in each row (or column) of the array. For the columns in the array above I want the result to be:

```<code>Array={4,5,6,7}
</code>```

If it helps, the maximum is always going to be the topmost number for a column and leftmost number for a row.

I would like a worksheet formula rather than a VBA function.

答:
With a named range Rng and values as posted in original post try this formula.

```<code>=SUBTOTAL(4,OFFSET(INDEX(Rng,1,1),,COLUMN(Rng)-MIN(COLUMN(Rng)),ROWS(Rng)))
</code>```

It returns an array of max of each column {4,5,6,7}

This returns a max of each row.

```<code>=SUBTOTAL(4,OFFSET(INDEX(Rng,1,1),ROW(Rng)-MIN(ROW(Rng)),,,COLUMNS(Rng)))
</code>```

and an array {7;6;5;4}.

Body:
In Excel I have a named range that contains an array, for example like the array below.

0 0 0 7
0 0 6 5
0 5 3 2
4 3 2 1

I'd like to find the maximum value in each row (or column) of the array. For the columns in the array above I want the result to be:

Array={4,5,6,7}

If it helps, the maximum is always going to be the topmost number for a column and leftmost number for a row.

I would like a worksheet formula rather than a VBA function.

Body:
With a named range Rng and values as posted in original post try this formula.

=SUBTOTAL(4,OFFSET(INDEX(Rng,1,1),,COLUMN(Rng)-MIN(COLUMN(Rng)),ROWS(Rng)))

It returns an array of max of each column {4,5,6,7}

This returns a max of each row.

=SUBTOTAL(4,OFFSET(INDEX(Rng,1,1),ROW(Rng)-MIN(ROW(Rng)),,,COLUMNS(Rng)))

and an array {7;6;5;4}.


问:
web request from the user browser
is it possible to send a web request from the user browser to another api and then process the result sent back??

im trying the following ajax code but its not working, i was wondering whether is it possible or not and if its a yes how can i implement it ...

```<code>$(document).ready(function() {

        $.ajax({
            type: "GET",
            url: "http://api.ipinfodb.com/v2/ip_query.php?key=a9a2b0ec2c4724dd95286761777b09f1c8e82894de277a5b9d7175fa5275f2da&ip=&output=xml",
            dataType: "xml",
            success: function(xml) {
                alert("sucess");
                $(xml).find('Ip').each(function() {
                    var ip = $(this).find('Ip').text();
                    alert(ip);

                });
            }
        });

    });
</code>```

答: Due to same origin policy restriction you are pretty limited to sending AJAX requests to your own domain only. JSONP is a common workaround but the remote site needs to support it. Another workaround consists in crating a server side script on your domain which will serve as a bridge between your domain and the remote domain and it will simply delegate the AJAX request sent to it from javascript.</p>

ContentLicense: CC BY-SA 2.5

Title: web request from the user browser

Body:
is it possible to send a web request from the user browser to another api and then process the result sent back??

im trying the following ajax code but its not working, i was wondering whether is it possible or not and if its a yes how can i implement it ...

$(document).ready(function() {

        $.ajax({
            type: "GET",
            url: "http://api.ipinfodb.com/v2/ip_query.php?key=a9a2b0ec2c4724dd95286761777b09f1c8e82894de277a5b9d7175fa5275f2da&ip=&output=xml",
            dataType: "xml",
            success: function(xml) {
                alert("sucess");
                $(xml).find('Ip').each(function() {
                    var ip = $(this).find('Ip').text();
                    alert(ip);

                });
            }
        });

    });


问:
Explanation for a code needed : Appending the values to list in python
Anyone explain this please......

```<code>def f(i,list1=[]):

     list1.append(i)

     return list1

f(1)

f(2)

print(f(3))
</code>```

Output: [1,2,3].

I cannot understand this, because everytime my list1 is initialized as a empty list.

Can anyone explain this??

答:
You should not include the list creation in the argument declaration.

This is because the line that says def f(i, list1=[]): actually creates a new list when it gets to the [].  This happens when the function is created.

Each time the function runs, it is re-using that same list object.

Think of it in terms of how the program runs, line by line.  In effect the def line ends up looking like this when it runs:

```<code>def f(i, list1=<a-new-list-that-I-just-created>):
</code>```

And each time the function is called, the list1 default value is not a new list, but the list that was created when the function was defined.

I believe this is what you want, if you want to avoid this, is:

```<code>def f(i, list1=None):
   if not list1:
       list1=[]
   list1.append(i)
   return list1
</code>```

Body:
Anyone explain this please......

def f(i,list1=[]):

     list1.append(i)

     return list1

f(1)

f(2)

print(f(3))

Output: [1,2,3].

I cannot understand this, because everytime my list1 is initialized as a empty list.

Can anyone explain this??

Body:
You should not include the list creation in the argument declaration.

This is because the line that says def f(i, list1=[]): actually creates a new list when it gets to the [].  This happens when the function is created.

Each time the function runs, it is re-using that same list object.

Think of it in terms of how the program runs, line by line.  In effect the def line ends up looking like this when it runs:

def f(i, list1=<a-new-list-that-I-just-created>):

And each time the function is called, the list1 default value is not a new list, but the list that was created when the function was defined.

I believe this is what you want, if you want to avoid this, is:

def f(i, list1=None):
   if not list1:
       list1=[]
   list1.append(i)
   return list1


问:
Custom adatper getView returns null pointer
In my app I have a listview with a custom adapter which is reloaded after a message was send. The app chrashes at some of the installations. I have in the app console the stack traces. Here the code:

```<code>class IconicAdapter extends ArrayAdapter<Integer> {
        Activity context;

        IconicAdapter(Activity context) {
            super(context, R.layout.message_layout, listItems);

            this.context = context;
        }

        public View getView(int position, View convertView, ViewGroup parent) {

                //you can access layout inflater by accessing hosting activity
                convertView = getActivity().getLayoutInflater().inflate(R.layout.message_layout, parent, false);

            JSONObject json_data = null;
            try {
                json_data = jArray.getJSONObject(position);
            } catch (JSONException e) {
            }

            try {
                tv = (TextView) convertView.findViewById(R.id.username);
                tv.setText(json_data.getString("username"));
</code>```

Here stack trace:

```<code>java.lang.NullPointerException:
  at com.testing.gold.CommunityFragment$IconicAdapter.getView (CommunityFragment.java:945)
  at android.widget.HeaderViewListAdapter.getView (HeaderViewListAdapter.java:232)
</code>```

The line 945: tv.setText(json_data.getString("username"));

答:
Use following code:
      class IconicAdapter extends ArrayAdapter {
    Activity context;</p>

```<code>IconicAdapter(Activity context) {
    super(context, R.layout.message_layout, listItems);

    this.context = context;
}

public View getView(int position, View convertView, ViewGroup parent) {
     convertView=LayoutInflater.inflate(R.layout.message_layout, null);
     JSONObject json_data = null;
     try {
        json_data = jArray.getJSONObject(position);

    } catch (JSONException e) {
         e.printStackTrace();
    }
 tv = (TextView) convertView.findViewById(R.id.username);

if(json_data!=null)
   tv.setText(json_data.getString("username"));
else
   tv.setText("")
</code>```

Body:
In my app I have a listview with a custom adapter which is reloaded after a message was send. The app chrashes at some of the installations. I have in the app console the stack traces. Here the code:

class IconicAdapter extends ArrayAdapter<Integer> {
        Activity context;

        IconicAdapter(Activity context) {
            super(context, R.layout.message_layout, listItems);

            this.context = context;
        }

        public View getView(int position, View convertView, ViewGroup parent) {

                //you can access layout inflater by accessing hosting activity
                convertView = getActivity().getLayoutInflater().inflate(R.layout.message_layout, parent, false);

            JSONObject json_data = null;
            try {
                json_data = jArray.getJSONObject(position);
            } catch (JSONException e) {
            }

            try {
                tv = (TextView) convertView.findViewById(R.id.username);
                tv.setText(json_data.getString("username"));

Here stack trace:

java.lang.NullPointerException:
  at com.testing.gold.CommunityFragment$IconicAdapter.getView (CommunityFragment.java:945)
  at android.widget.HeaderViewListAdapter.getView (HeaderViewListAdapter.java:232)

The line 945: tv.setText(json_data.getString("username"));

Body:
Use following code:
      class IconicAdapter extends ArrayAdapter {
    Activity context;

IconicAdapter(Activity context) {
    super(context, R.layout.message_layout, listItems);

    this.context = context;
}

public View getView(int position, View convertView, ViewGroup parent) {
     convertView=LayoutInflater.inflate(R.layout.message_layout, null);
     JSONObject json_data = null;
     try {
        json_data = jArray.getJSONObject(position);

    } catch (JSONException e) {
         e.printStackTrace();
    }
 tv = (TextView) convertView.findViewById(R.id.username);

if(json_data!=null)
   tv.setText(json_data.getString("username"));
else
   tv.setText("")


问:
Apollo/GraphQL: Field Type to Use for Timestamp?
I'm storing a value to a postgres field that is of type timestamp with time zone. I was defining the field as an int in my Apollo schema, but I'm getting this error message in the resolver:

column "apptDateTime" is of type timestamp with time zone but expression is of type integer

Looking up GraphQL data types, I don't yet see any type that is cited as corresponding to a field of type timestamp.

What's the correct field type to use in the Apollo schema for a field that is of type timestamp in the database?

答:
I find this way to work with input in forms, needed convert from client (input form) to the server, and from the server to  client (input form)

Graphql:

```<code>    updatedAt: String
</code>```

Sequelize:

```<code>    updatedAt: {  type: Sequelize.DATE },
</code>```

Postgresql:

```<code>    "createdAt" timestamp(6) with time zone DEFAULT now(),
</code>```

Value transform to the  Server:

```<code>  value  = dateToISO(value);
</code>```

Value transform to the  Client:

```<code>  if ( isNil(value) ) {
    value = '';
  } else {
    value  =  value.toLocaleDateString() +' '+ value.toLocaleTimeString();
  }
</code>```

the helpers:

```<code>let dateToISO = function (dateString) {
  if (!dateString) {
    return null;
  }
  let p = dateString.split(/\D/g);
  /* It's up your date on input in this case come from DD-MM-YYYY
    for MM-DD-YYY use: return [p[1], p[2], p[0]].join('-'); */
  return [p[2], p[1], p[0]].join('-');

};
</code>```

Body:
I find this way to work with input in forms, needed convert from client (input form) to the server, and from the server to  client (input form)

Graphql:

    updatedAt: String

Sequelize:

    updatedAt: {  type: Sequelize.DATE },

Postgresql:

    "createdAt" timestamp(6) with time zone DEFAULT now(),

Value transform to the  Server:

  value  = dateToISO(value);

Value transform to the  Client:

  if ( isNil(value) ) {
    value = '';
  } else {
    value  =  value.toLocaleDateString() +' '+ value.toLocaleTimeString();
  }

the helpers:

let dateToISO = function (dateString) {
  if (!dateString) {
    return null;
  }
  let p = dateString.split(/\D/g);
  /* It's up your date on input in this case come from DD-MM-YYYY
    for MM-DD-YYY use: return [p[1], p[2], p[0]].join('-'); */
  return [p[2], p[1], p[0]].join('-');

};


问:
How do I get the average of a count in Microsoft SQL Server 2008
How can I get the average of this count? </p>

```<code>SELECT
    driver,
    COUNT(order_number) as month_total
FROM
    Unloads
WHERE
    completiondate BETWEEN '11-06-2017' AND '11-10-2017'
GROUP BY
    driver
ORDER BY
    month_total DESC;
</code>```

答:
This may seem like overkill, but data over a time series can have gaps, so to reliably average by month you need to ensure there are no gaps. A way (there are many) is to do something like the following so that the ranges exist as rows, then left join the data to those. The other thing I particularly caution you on is to avoid using "between" for date ranges. Use >= and < as you see below this ensures you don't accidentally over count for data sitting one the upper boundary dates.

```<code>declare @start_dt date;
set @start_dt = '20170601';

select
       u.driver, period_start_dt, period_end_dt
     , count(completiondate)            montly_count
     , AVG(COUNT(completiondate))OVER() avg_montly_count
from (
        select
               dateadd(month,m.n,start_dt)   period_start_dt
             , dateadd(month,m.n+1,start_dt) period_end_dt
             , m.n                           month_no
        from (
               select @start_dt start_dt ) seed
        cross join (select 0 n union all
                    select 1 union all select 2 union all select 3 union all
                    select 4 union all select 5 union all select 6 union all
                    select 7 union all select 8 union all select 9 union all
                    select 10 union all select 11
                   ) m
     ) r

-- LEFT JOIN YOUR DATA
LEFT JOIN unloads u on u.completiondate >= r.period_start_dt and u.completiondate < r.period_end_dt

WHERE period_start_dt >= '20170601' and period_start_dt < '20171001'

group by
       u.driver , period_start_dt, period_end_dt
order by
       period_start_dt,  u.driver
</code>```

Demo

Body:
How can I get the average of this count?

SELECT
    driver,
    COUNT(order_number) as month_total
FROM
    Unloads
WHERE
    completiondate BETWEEN '11-06-2017' AND '11-10-2017'
GROUP BY
    driver
ORDER BY
    month_total DESC;

Body:
This may seem like overkill, but data over a time series can have gaps, so to reliably average by month you need to ensure there are no gaps. A way (there are many) is to do something like the following so that the ranges exist as rows, then left join the data to those. The other thing I particularly caution you on is to avoid using "between" for date ranges. Use >= and < as you see below this ensures you don't accidentally over count for data sitting one the upper boundary dates.

declare @start_dt date;
set @start_dt = '20170601';

select
       u.driver, period_start_dt, period_end_dt
     , count(completiondate)            montly_count
     , AVG(COUNT(completiondate))OVER() avg_montly_count
from (
        select
               dateadd(month,m.n,start_dt)   period_start_dt
             , dateadd(month,m.n+1,start_dt) period_end_dt
             , m.n                           month_no
        from (
               select @start_dt start_dt ) seed
        cross join (select 0 n union all
                    select 1 union all select 2 union all select 3 union all
                    select 4 union all select 5 union all select 6 union all
                    select 7 union all select 8 union all select 9 union all
                    select 10 union all select 11
                   ) m
     ) r

-- LEFT JOIN YOUR DATA
LEFT JOIN unloads u on u.completiondate >= r.period_start_dt and u.completiondate < r.period_end_dt

WHERE period_start_dt >= '20170601' and period_start_dt < '20171001'

group by
       u.driver , period_start_dt, period_end_dt
order by
       period_start_dt,  u.driver

Demo


问:
Does Clear Data on App Settings clears all Android KeyStore stored for that certain app?
Just want to know if Clear Data in App's Setting clears all Android Keystore stored in that certain app? Or it leaves certain bits of data?

Android Keystore I'm referring to is similar to this KeyStore. See Tutorials below.

From Android Developer

From Medium Tutorial

From Android Authority Tutorial

答:
Clear Data in App's Setting will clear only the data, created / generated run-time by user. Like, preferences, database etc.

It will not clear data, stored at the time of app building


问:
SORTING Hierarchical Queries in SQL Server 2005
I have following issue: I have a table for maintaining the hierarchical data. I'd like to use CTE from SQL 2005.

```<code>WITH tree (id, parentid, code, name) AS
(
    SELECT id, ofs.ParentID, ofs.code, ofs.name
      FROM OrganizationFeatures ofs
     WHERE ofs.ParentID IS NULL

    UNION ALL

    SELECT ofs.id, ofs.ParentID, ofs.code, ofs.name
      FROM OrganizationFeatures ofs
      JOIN tree ON tree.ID = ofs.ParentID
)

select * from tree
</code>```

But I'd like to sort by code and the result shold be as following:

```<code>1
1/1
1/1/1
1/1/2
1/2/1
1/2/2
2
4/1
</code>```

etc. Any ideas?

答:
To get the concatenated values, you need to do it in the with.

To sort, you need to add an order by in the last select.

```<code>WITH tree (id, parentid, code, name) AS
(
    SELECT id, ofs.ParentID, ofs.code, ofs.name
      FROM OrganizationFeatures ofs
     WHERE ofs.ParentID IS NULL

    UNION ALL

    SELECT ofs.id, ofs.ParentID, tree.code+'/'+ofs.code, ofs.name
      FROM OrganizationFeatures ofs
      JOIN tree ON tree.ID = ofs.ParentID
)

select * from tree order by code
</code>```

Also, if code is not a varchar, you will have to convert the code columns in this bit of code (tree.code+'/'+ofs.code) for it to work.

OwnerDisplayName: frantisek

Body:
I have following issue: I have a table for maintaining the hierarchical data. I'd like to use CTE from SQL 2005.

WITH tree (id, parentid, code, name) AS
(
    SELECT id, ofs.ParentID, ofs.code, ofs.name
      FROM OrganizationFeatures ofs
     WHERE ofs.ParentID IS NULL

    UNION ALL

    SELECT ofs.id, ofs.ParentID, ofs.code, ofs.name
      FROM OrganizationFeatures ofs
      JOIN tree ON tree.ID = ofs.ParentID
)

select * from tree

But I'd like to sort by code and the result shold be as following:

1
1/1
1/1/1
1/1/2
1/2/1
1/2/2
2
4/1

etc. Any ideas?

LastEditorDisplayName: Cade Roux

Body:
To get the concatenated values, you need to do it in the with.

To sort, you need to add an order by in the last select.

WITH tree (id, parentid, code, name) AS
(
    SELECT id, ofs.ParentID, ofs.code, ofs.name
      FROM OrganizationFeatures ofs
     WHERE ofs.ParentID IS NULL

    UNION ALL

    SELECT ofs.id, ofs.ParentID, tree.code+'/'+ofs.code, ofs.name
      FROM OrganizationFeatures ofs
      JOIN tree ON tree.ID = ofs.ParentID
)

select * from tree order by code

Also, if code is not a varchar, you will have to convert the code columns in this bit of code (tree.code+'/'+ofs.code) for it to work.

OwnerDisplayName: Loki

LastEditorDisplayName: Loki


问:
predicting proper regular expression from seeing target string
I want to know it is possible to predict proper regular expression by seeing several strings. For example, regex ^[a-z0-9_-]{3,16}$ will match my-us3r_n4m3 and ^[a-z0-9_-]{6,18}$ match myp4ssw0rd. But after seeing my-us3r_n4m3, is it possible output ^[a-z0-9_-]{3,16}$ or ^[a-z0-9_-]{6,18}$from seeing myp4ssw0rd.

I guess this would be stupid question, and I don't want to predict exact regular expression.

Anyone who has idea for this, pls let me know.
Thanks.

答:
The problem is defining what is "proper". If you simply mean well-formed, then as mentioned by someone else .* will match anything, end of story. Furthermore, there's an infinite number of other possible regular expressions that will match your string. The two constrains that you may want to place on your problem to get meaningful solution is:

The regular expression should match the given examples and nothing else

The regular expression should be simple ("parsimonious") in some way.

If you loosen the first requirement so that you accept approximate answers, the problem becomes a classic sequence classification problem. Then, one possible way to handle is to train a hidden markov model with a limited vocabulary (in terms of what is available in the language of regular expressions) and convert it to a regular expression.


问:
how to put carousel scroll arrow key to middle of the page
I have bootstrap carousel scroll arrows key in left and right side. but currently it is on the top side of the banner page. but I need put it middle of the page. My css class is this for arrow keys.

```<code>.carousel-control.left {margin-left: -85px; color: black;}
.carousel-control.right {margin-right: -85px; color: black;}
</code>```

how can put my arrow keys to middle of the page?

答:
 Content

```

Body:
I have bootstrap carousel scroll arrows key in left and right side. but currently it is on the top side of the banner page. but I need put it middle of the page. My css class is this for arrow keys.

.carousel-control.left {margin-left: -85px; color: black;}
.carousel-control.right {margin-right: -85px; color: black;}

how can put my arrow keys to middle of the page?

Body:
<div style="display:table;height: 100vh;width: 100%;">
  <div style="display: table-cell;padding: 0;height: 100vh;vertical-align: middle;text-align: center;">
  <p style="background:red;display:inline-block;padding:50px"> Content </p>
  </div>
</div>


问:
Extend the existing Windows app expired certificate
One of our windows 8.1 app got its certificate expired and we are not able to generate new builds.Is there a way to extend the same certificate for upcoming builds.

Right now i tried with post-build event and couldn't achieve the same.

```<code>if $(SolutionName) == Installer ("C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe" sign /fd SHA256 /a /f "$(ProjectDir)..\..\Build\CodeSigning.pfx" /tr http://tsa.starfieldtech.com "$(TargetDir)AppPackages\my_app\my_app.appxbundle")
</code>```

Refernce Add timestamp to signed AppX bundle

In this post build which certificate to be mapped. Expired certificate or a new certificate

Note: There is an option to add new certificate but it changes the app "Package family name". I don'n need to change my package family name since the data in old package is needed.

答:
The Package Family Name (PFN) consists of two parts,

The first is the Package name you choose.

The second is a hash of the Publisher name, which is the Publisher field of the signing certificate.

So when renewing the signing certificate, make sure the new cert's Publisher stays the same, then the Package Family Name won't change.

Body:
One of our windows 8.1 app got its certificate expired and we are not able to generate new builds.Is there a way to extend the same certificate for upcoming builds.

Right now i tried with post-build event and couldn't achieve the same.

if $(SolutionName) == Installer ("C:\Program Files (x86)\Windows Kits\10\bin\x86\signtool.exe" sign /fd SHA256 /a /f "$(ProjectDir)..\..\Build\CodeSigning.pfx" /tr http://tsa.starfieldtech.com "$(TargetDir)AppPackages\my_app\my_app.appxbundle")

Refernce Add timestamp to signed AppX bundle

In this post build which certificate to be mapped. Expired certificate or a new certificate

Note: There is an option to add new certificate but it changes the app "Package family name". I don'n need to change my package family name since the data in old package is needed.


问:
Laravel Scope and Search results
I'm working with laravel 5.5 and I made scope for my products in Product.php model:

```<code>public function scopeApproved($query)
{
    return $query->where('publish', 1);
}
</code>```

Taken from laravel website.

Then I have this code below to show my search results.

```<code>public function search()
{
    $search = request('search');
    $searchType = request('searchType');

    if (strcmp($searchType, "posts") == 0) {
        $posts = Post::where('title', 'like', "%{$search}%")
            ->orWhere('description', 'like', "%{$search}%")
            ->get();
    } elseif (strcmp($searchType, "products") == 0) {
        $products = Product::where('title', 'like', "%{$search}%")
            ->orWhere('description', 'like', "%{$search}%")
            ->get();
    }

    return view('frontend.search', compact('posts', 'products'));
}
</code>```

The problem with that is even if my product publish column is set to 0 still will pop in search results.

same goes for products list, still shows in website.

How can I fix that?

答:
Your issue is you are adding local scope rather the global scope.

You can still use you local scope doing Product::approved()

But for global scope you need to create boot method in your Product.php like so:

```<code>protected static function boot()
{
    parent::boot();

    static::addGlobalScope('publish', function (Builder $builder) {
        $builder->where('publish', 1);
    });
}
</code>```

if you want product  without global scope Product::withoutGlobalScopes()->get();

That should do it.

Also have a look at https://laravel.com/docs/5.5/eloquent#global-scopes

Title: Laravel Scope and Search results

Body:
I'm working with laravel 5.5 and I made scope for my products in Product.php model:

public function scopeApproved($query)
{
    return $query->where('publish', 1);
}

Taken from laravel website.

Then I have this code below to show my search results.

public function search()
{
    $search = request('search');
    $searchType = request('searchType');

    if (strcmp($searchType, "posts") == 0) {
        $posts = Post::where('title', 'like', "%{$search}%")
            ->orWhere('description', 'like', "%{$search}%")
            ->get();
    } elseif (strcmp($searchType, "products") == 0) {
        $products = Product::where('title', 'like', "%{$search}%")
            ->orWhere('description', 'like', "%{$search}%")
            ->get();
    }

    return view('frontend.search', compact('posts', 'products'));
}

The problem with that is even if my product publish column is set to 0 still will pop in search results.

same goes for products list, still shows in website.

How can I fix that?

Body:
Your issue is you are adding local scope rather the global scope.

You can still use you local scope doing Product::approved()

But for global scope you need to create boot method in your Product.php like so:

protected static function boot()
{
    parent::boot();

    static::addGlobalScope('publish', function (Builder $builder) {
        $builder->where('publish', 1);
    });
}

if you want product  without global scope Product::withoutGlobalScopes()->get();

That should do it.

Also have a look at https://laravel.com/docs/5.5/eloquent#global-scopes


问:
Python: Pass or Sleep for long running processes?
I am writing an queue processing application which uses threads for waiting on and responding to queue messages to be delivered to the app.  For the main part of the application, it just needs to stay active.  For a code example like:

```
while True:
  pass
```

or

```
while True:
  time.sleep(1)
```

Which one will have the least impact on a system?  What is the preferred way to do nothing, but keep a python app running?

答:
Running a method as a background thread with sleep in Python:</p>
```<code>    import threading
    import time

    class ThreadingExample(object):
        """ Threading example class
        The run() method will be started and it will run in the background
        until the application exits.
        """

        def __init__(self, interval=1):
            """ Constructor
            :type interval: int
            :param interval: Check interval, in seconds
            """
            self.interval = interval

            thread = threading.Thread(target=self.run, args=())
            thread.daemon = True                            # Daemonize thread
            thread.start()                                  # Start the execution

        def run(self):
            """ Method that runs forever """
            while True:
                # Do something
                print('Doing something imporant in the background')

                time.sleep(self.interval)

    example = ThreadingExample()
    time.sleep(3)
    print('Checkpoint')
    time.sleep(2)
    print('Bye')
</code>```

OwnerDisplayName: Crad

Body:
I am writing an queue processing application which uses threads for waiting on and responding to queue messages to be delivered to the app.  For the main part of the application, it just needs to stay active.  For a code example like:

while True:
  pass

or

while True:
  time.sleep(1)

Which one will have the least impact on a system?  What is the preferred way to do nothing, but keep a python app running?

Body:
Running a method as a background thread with sleep in Python:

    import threading
    import time

    class ThreadingExample(object):
        """ Threading example class
        The run() method will be started and it will run in the background
        until the application exits.
        """

        def __init__(self, interval=1):
            """ Constructor
            :type interval: int
            :param interval: Check interval, in seconds
            """
            self.interval = interval

            thread = threading.Thread(target=self.run, args=())
            thread.daemon = True                            # Daemonize thread
            thread.start()                                  # Start the execution

        def run(self):
            """ Method that runs forever """
            while True:
                # Do something
                print('Doing something imporant in the background')

                time.sleep(self.interval)

    example = ThreadingExample()
    time.sleep(3)
    print('Checkpoint')
    time.sleep(2)
    print('Bye')


问:
Logging Web application using Spring AOP and AspectJ
I'm new at Spring and JSF and my BOSS asked me add logging to a web application built with JSF Maven Spring here is my Code

LoggingBean.Java

```<code> package ma.nawarit.logger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.emory.mathcs.backport.java.util.Arrays;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

@Aspect
public class LoggerBean {

        private final Logger log = LoggerFactory.getLogger(this.getClass());
        //Before
        @Before("execution(public * *(..))")
        public void logBefore(JoinPoint joinPoint) {
            //log.debug(point.getSignature().getName() + " called...");
            System.out.println("logBefore() is running!");
            System.out.println("Method Name : " + joinPoint.getSignature().getName());
            System.out.println("******");
        }

        //After
        @After("execution(public * *(..))")
        public void logAfter(JoinPoint joinPoint) {
            //log.debug(point.getSignature().getName() + " called...");
            System.out.println("logAfter() is running!");
            System.out.println("Method Name : " + joinPoint.getSignature().getName());
            System.out.println("******");
        }

        //Log After Returning
        @AfterReturning("execution(public * *(..))")
        public void logAfterReturning(JoinPoint joinPoint, Object result) {
            //log.debug(point.getSignature().getName() + " called...");
            System.out.println("logAfterReturning() is running!");
            System.out.println("Method Name : " + joinPoint.getSignature().getName());
            System.out.println("Method returned value is : " + result);
            System.out.println("******");
        }

        //Log After Throwing Exception
        @AfterThrowing(pointcut = "execution(public * *(..))",throwing= "error")
        public void logAfterThrowing(JoinPoint joinPoint, Throwable error) {

            System.out.println("logAfterThrowing() is running!");
            System.out.println("Method Name : " + joinPoint.getSignature().getName());
            System.out.println("Exception : " + error);
            System.out.println("******");
        }

        //Log Arround Interceptor
        @Around("execution(public * *(..))")
           public void logAround(ProceedingJoinPoint joinPoint) throws Throwable {
                System.out.println("logAround() is running!");
                System.out.println("Method Name : " + joinPoint.getSignature().getName());
                System.out.println("Method Arguments : " + Arrays.toString(joinPoint.getArgs()));

                System.out.println("Around before is running!");
                joinPoint.proceed(); //continue on the intercepted method
                System.out.println("Around after is running!");
                System.out.println("******");
           }

}
</code>```

My Spring Configuration  applicationContext-aop.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">

    <aop:aspectj-autoproxy />

    <!-- Aspect -->
    <bean id="logAspect" class="ma.nawarit.logger.LoggerBean" />

    <aop:config>

        <aop:aspect id="aspectLoggging" ref="logAspect" >

            <!-- @Before -->
            <aop:pointcut id="pointCutBefore"
                expression="execution(public * *(..))" />

            <aop:before method="logBefore" pointcut-ref="pointCutBefore" />

            <!-- @After -->
            <aop:pointcut id="pointCutAfter"
                expression="execution(public * *(..))" />

            <aop:after method="logAfter" pointcut-ref="pointCutAfter" />

            <!-- @AfterReturning -->
            <aop:pointcut id="pointCutAfterReturning"
                expression="execution(public * *(..))" />

            <aop:after-returning method="logAfterReturning" returning="result"
                pointcut-ref="pointCutAfterReturning" />

            <!-- @AfterThrowing -->
            <aop:pointcut id="pointCutAfterThrowing"
                expression="execution(public * *(..))" />

            <aop:after-throwing method="logAfterThrowing" throwing="error"
                pointcut-ref="pointCutAfterThrowing"  />

            <!-- @Around -->
            <aop:pointcut id="pointCutAround"
                expression="execution(public * *(..))" />

            <aop:around method="logAround" pointcut-ref="pointCutAround"  />
        </aop:aspect>
    </aop:config>
</beans>
</code>```

My Web.xml context param

```<code><context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/conf/spring/global-applicationContext-manageable.xml,
            /WEB-INF/conf/spring/global-applicationContext.xml,
            /WEB-INF/conf/spring/applicationContext-engine.xml,
            /WEB-INF/conf/spring/applicationContext-periodicProcess.xml,
            /WEB-INF/conf/spring/applicationContext-jbpm.xml,
            /WEB-INF/conf/spring/applicationContext-batch.xml,
            /WEB-INF/conf/spring/applicationContextSecurity-jasypt-dynamic.xml,
            /WEB-INF/jasperSpring-servlet.xml,
            /WEB-INF/conf/spring/applicationContext-aop.xml
        </param-value>
    </context-param>
</code>```

After i run my App i get this Error formal unbound in pointcut Please Help me i tried différents configurations but no result

```<code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserManageableServiceBase' defined in ServletContext resource [/WEB-INF/conf/spring/manageable/compagnie-applicationContext-manageable.xml]: Cannot resolve reference to bean 'userDao' while setting bean property 'dao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot create inner bean 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' of type [ma.nawarit.checker.compagnie.UserDaoImpl] while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:464)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4643)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5105)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:671)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.__invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot create inner bean 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' of type [ma.nawarit.checker.compagnie.UserDaoImpl] while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 48 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
    ... 58 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 64 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 74 more
Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:193)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:182)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:163)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:209)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:263)
    at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:295)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 80 more
</code>```

答:
Your @AfterReturning declaration is incorrect, you forgot to specify the name of the argument containing the return value.

```<code>@AfterReturning(pointcut="execution(public * *(..))", returning="result")
public void logAfterReturning(JoinPoint joinPoint, Object result) {
...
}
</code>```

Body:
I'm new at Spring and JSF and my BOSS asked me add logging to a web application built with JSF Maven Spring here is my Code

LoggingBean.Java

 package ma.nawarit.logger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import edu.emory.mathcs.backport.java.util.Arrays;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

@Aspect
public class LoggerBean {

        private final Logger log = LoggerFactory.getLogger(this.getClass());
        //Before
        @Before("execution(public * *(..))")
        public void logBefore(JoinPoint joinPoint) {
            //log.debug(point.getSignature().getName() + " called...");
            System.out.println("logBefore() is running!");
            System.out.println("Method Name : " + joinPoint.getSignature().getName());
            System.out.println("******");
        }

        //After
        @After("execution(public * *(..))")
        public void logAfter(JoinPoint joinPoint) {
            //log.debug(point.getSignature().getName() + " called...");
            System.out.println("logAfter() is running!");
            System.out.println("Method Name : " + joinPoint.getSignature().getName());
            System.out.println("******");
        }

        //Log After Returning
        @AfterReturning("execution(public * *(..))")
        public void logAfterReturning(JoinPoint joinPoint, Object result) {
            //log.debug(point.getSignature().getName() + " called...");
            System.out.println("logAfterReturning() is running!");
            System.out.println("Method Name : " + joinPoint.getSignature().getName());
            System.out.println("Method returned value is : " + result);
            System.out.println("******");
        }

        //Log After Throwing Exception
        @AfterThrowing(pointcut = "execution(public * *(..))",throwing= "error")
        public void logAfterThrowing(JoinPoint joinPoint, Throwable error) {

            System.out.println("logAfterThrowing() is running!");
            System.out.println("Method Name : " + joinPoint.getSignature().getName());
            System.out.println("Exception : " + error);
            System.out.println("******");
        }

        //Log Arround Interceptor
        @Around("execution(public * *(..))")
           public void logAround(ProceedingJoinPoint joinPoint) throws Throwable {
                System.out.println("logAround() is running!");
                System.out.println("Method Name : " + joinPoint.getSignature().getName());
                System.out.println("Method Arguments : " + Arrays.toString(joinPoint.getArgs()));

                System.out.println("Around before is running!");
                joinPoint.proceed(); //continue on the intercepted method
                System.out.println("Around after is running!");
                System.out.println("******");
           }

}

My Spring Configuration  applicationContext-aop.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-3.0.xsd ">

    <aop:aspectj-autoproxy />

    <bean id="logAspect" class="ma.nawarit.logger.LoggerBean" />

    <aop:config>

        <aop:aspect id="aspectLoggging" ref="logAspect" >

            <aop:pointcut id="pointCutBefore"
                expression="execution(public * *(..))" />

            <aop:before method="logBefore" pointcut-ref="pointCutBefore" />

            <aop:pointcut id="pointCutAfter"
                expression="execution(public * *(..))" />

            <aop:after method="logAfter" pointcut-ref="pointCutAfter" />

            <aop:pointcut id="pointCutAfterReturning"
                expression="execution(public * *(..))" />

            <aop:after-returning method="logAfterReturning" returning="result"
                pointcut-ref="pointCutAfterReturning" />

            <aop:pointcut id="pointCutAfterThrowing"
                expression="execution(public * *(..))" />

            <aop:after-throwing method="logAfterThrowing" throwing="error"
                pointcut-ref="pointCutAfterThrowing"  />

            <aop:pointcut id="pointCutAround"
                expression="execution(public * *(..))" />

            <aop:around method="logAround" pointcut-ref="pointCutAround"  />
        </aop:aspect>
    </aop:config>
</beans>

My Web.xml context param

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/conf/spring/global-applicationContext-manageable.xml,
            /WEB-INF/conf/spring/global-applicationContext.xml,
            /WEB-INF/conf/spring/applicationContext-engine.xml,
            /WEB-INF/conf/spring/applicationContext-periodicProcess.xml,
            /WEB-INF/conf/spring/applicationContext-jbpm.xml,
            /WEB-INF/conf/spring/applicationContext-batch.xml,
            /WEB-INF/conf/spring/applicationContextSecurity-jasypt-dynamic.xml,
            /WEB-INF/jasperSpring-servlet.xml,
            /WEB-INF/conf/spring/applicationContext-aop.xml
        </param-value>
    </context-param>

After i run my App i get this Error formal unbound in pointcut Please Help me i tried différents configurations but no result

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserManageableServiceBase' defined in ServletContext resource [/WEB-INF/conf/spring/manageable/compagnie-applicationContext-manageable.xml]: Cannot resolve reference to bean 'userDao' while setting bean property 'dao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot create inner bean 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' of type [ma.nawarit.checker.compagnie.UserDaoImpl] while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:464)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4643)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5105)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:671)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.__invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot create inner bean 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' of type [ma.nawarit.checker.compagnie.UserDaoImpl] while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 48 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ma.nawarit.checker.compagnie.UserDaoImpl#713616c0' defined in ServletContext resource [/WEB-INF/conf/spring/dao/compagnie-applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
    ... 58 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 64 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/conf/spring/global-applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 74 more
Caused by: java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
    at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:207)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:193)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:182)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.getClassFilter(AspectJExpressionPointcut.java:163)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:209)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:263)
    at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:295)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
    at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1461)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    ... 80 more

Body:
Your @AfterReturning declaration is incorrect, you forgot to specify the name of the argument containing the return value.

@AfterReturning(pointcut="execution(public * *(..))", returning="result")
public void logAfterReturning(JoinPoint joinPoint, Object result) {
...
}


问:
Is there any spreadsheet which use a formula repository instead of writing several copies directly in the cell?
I like speradsheet programs, but there is a disturbing thing with them: the formulas must be entered in the cells. It has several withdraws:

I need to scan thru all the cells to see, what's going in a sheet;

if I change a formula, I must copy it to several cells;

of course, sometimes I forget copy new formulas into all the cells;

it eats up lot of space, the same long formula is repeated several times.

Have you ever seen a spreadsheet software which has a kind of formula repository? Does it exists?

(I'm working now on a spreadsheet software, which is more specialized than desktop spreadsheets, and I'm using one formula per row - that's where the question comes.)

Also, spreadsheets are dataflow systems, and it's strange, that there are no pre-made reusable components, which is the base concept of dataflow systems. In spreadsheets, all components are used once, which is very bad design.

答:
Since Office 2007, MS Excel has supported named formulae, which can be held at workbook- or worksheet- level, and can subsequently be used in many cells.

See this link or this for an explanation