Spring boot Spring MVC控制器被忽略

Spring boot Spring MVC控制器被忽略,spring-boot,spring-mvc,spring-security,Spring Boot,Spring Mvc,Spring Security,我已经开始玩Springboot和SpringMVC了 我没有遇到任何问题,但现在我正试图利用安全性 对于以下pom、controller和curl请求,curl请求被完全忽略 如果我用debug运行,在控制器中有一个停止点,它永远不会到达那里。 没有错误消息,但有数百行否定匹配 我的控制器未显示在映射下 我错过了什么 聚甲醛 映射 从映射日志来看,您所拥有的数据rest依赖关系似乎没有从项目中清除 我认为尝试重新导入项目应该可以解决这个问题。 此外,还应使用curl如下: curl -d &q

我已经开始玩Springboot和SpringMVC了

我没有遇到任何问题,但现在我正试图利用安全性

对于以下pom、controller和curl请求,curl请求被完全忽略

如果我用debug运行,在控制器中有一个停止点,它永远不会到达那里。 没有错误消息,但有数百行否定匹配

我的控制器未显示在映射下

我错过了什么

聚甲醛 映射
从映射日志来看,您所拥有的数据rest依赖关系似乎没有从项目中清除

我认为尝试重新导入项目应该可以解决这个问题。 此外,还应使用
curl
如下:

curl -d "address1=410SouthMain&address2=&city=Romeo&state=MI&zip=78723" -X POST http://localhost:8080/validateAddress

如果您只想调试安全性,可以在application.properties中使用:
logging.level.org.springframework.security=debug
。请提供并使用您的安全配置。盲目猜测:您正在执行post并且csrf保护已启用?当您更改pom中的依赖项时,请始终记住执行
mvn clean compile
import java.util.ArrayList;
import java.util.List;

import org.xxx.address.beans.AddressBean;
import org.xxx.address.beans.AddressList;
import org.xxx.address.service.usps.UspsAddressValidator;
import org.xxx.address.usps.AddressValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@Controller
public class ValidationRest {

    Logger logger = LoggerFactory.getLogger(getClass());
    
    public ValidationRest() {
    }
    
    @PostMapping(value="/validateAddress")
    public String validateAddress(
            @ModelAttribute String address1,
            @ModelAttribute String address2,
            @ModelAttribute String     city,
            @ModelAttribute String     state,
            @ModelAttribute String       zip,
            Model model) throws AddressValidationException {
        AddressBean address = new AddressBean(address1,address2,city,state,zip);
        List<AddressBean> list = new ArrayList<AddressBean>();
        list.add(address);
        UspsAddressValidator validator = new UspsAddressValidator();
         List<AddressBean> response = null;
        try {
            response = validator.validate(list);
        } catch (AddressValidationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw e;
        }
        model.addAttribute("response",response);
        return "validatedAddress";
    }
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.5.0)

INFO  - 11:55:02,777 AddressApplication - Starting AddressApplication v0.0.1-SNAPSHOT using Java 14.0.2 on atx with PID 2737903 (/home/jjs/git/diamond-21-windoze/javautil/address-services/target/address-services-0.0.1-SNAPSHOT.jar started by jjs in /home/jjs/git/diamond-21-windoze/javautil/address-services)
INFO  - 11:55:02,777 AddressApplication - No active profile set, falling back to default profiles: default
Jun 09, 2021 11:55:03 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service [Tomcat]
Jun 09, 2021 11:55:03 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet engine: [Apache Tomcat/9.0.46]
Jun 09, 2021 11:55:03 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring embedded WebApplicationContext
INFO  - 11:55:04,220 AddressApplication - Started AddressApplication in 1.74 seconds (JVM running for 2.089)

Negative matches:
-----------------

   ActiveMQAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)

   AopAutoConfiguration.AspectJAutoProxyingConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.aspectj.weaver.Advice' (OnClassCondition)

   ArtemisAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'javax.jms.ConnectionFactory' (OnClassCondition)

   continues for hundreds of lines.
DEBUG Mappings - 
    o.s.d.r.w.RepositoryController:
    {OPTIONS [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForRepositories()
    {HEAD [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForRepositories()
    {GET [/ || ], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: listRepositories()
DEBUG Mappings - 
    o.s.d.r.w.RepositoryEntityController:
    {POST [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: postCollectionResource(RootResourceInformation,PersistentEntityResource,PersistentEntityResourceAssembler,String)
    {OPTIONS [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForItemResource(RootResourceInformation)
    {HEAD [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForItemResource(RootResourceInformation,Serializable,PersistentEntityResourceAssembler)
    {GET [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: getItemResource(RootResourceInformation,Serializable,PersistentEntityResourceAssembler,HttpHeaders)
    {PUT [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: putItemResource(RootResourceInformation,PersistentEntityResource,Serializable,PersistentEntityResourceAssembler,ETag,String)
    {PATCH [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: patchItemResource(RootResourceInformation,PersistentEntityResource,Serializable,PersistentEntityResourceAssembler,ETag,String)
    {DELETE [/{repository}/{id}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deleteItemResource(RootResourceInformation,Serializable,ETag)
    {OPTIONS [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForCollectionResource(RootResourceInformation)
    {HEAD [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headCollectionResource(RootResourceInformation,DefaultedPageable)
    {GET [/{repository}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: getCollectionResource(RootResourceInformation,DefaultedPageable,Sort,PersistentEntityResourceAssembler)
    {GET [/{repository}], produces [application/x-spring-data-compact+json || text/uri-list]}: getCollectionResourceCompact(RootResourceInformation,DefaultedPageable,Sort,PersistentEntityResourceAssembler)
DEBUG Mappings - 
    o.s.d.r.w.RepositoryPropertyReferenceController:
    {GET [/{repository}/{id}/{property}/{propertyId}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: followPropertyReference(RootResourceInformation,Serializable,String,String,PersistentEntityResourceAssembler)
    {GET [/{repository}/{id}/{property}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: followPropertyReference(RootResourceInformation,Serializable,String,PersistentEntityResourceAssembler)
    {DELETE [/{repository}/{id}/{property}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deletePropertyReference(RootResourceInformation,Serializable,String)
    {GET [/{repository}/{id}/{property}], produces [text/uri-list]}: followPropertyReferenceCompact(RootResourceInformation,Serializable,String,HttpHeaders,PersistentEntityResourceAssembler)
    {[PATCH, PUT, POST] [/{repository}/{id}/{property}], consumes [application/json || application/x-spring-data-compact+json || text/uri-list], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: createPropertyReference(RootResourceInformation,HttpMethod,CollectionModel,Serializable,String)
    {DELETE [/{repository}/{id}/{property}/{propertyId}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: deletePropertyReferenceId(RootResourceInformation,Serializable,String,String)
DEBUG Mappings - 
    o.s.d.r.w.RepositorySearchController:
    {OPTIONS [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForSearches(RootResourceInformation)
    {HEAD [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForSearches(RootResourceInformation)
    {GET [/{repository}/search], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: listSearches(RootResourceInformation)
    {GET [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: executeSearch(RootResourceInformation,MultiValueMap,String,DefaultedPageable,Sort,PersistentEntityResourceAssembler,HttpHeaders)
    {GET [/{repository}/search/{search}], produces [application/x-spring-data-compact+json]}: executeSearchCompact(RootResourceInformation,HttpHeaders,MultiValueMap,String,String,DefaultedPageable,Sort,PersistentEntityResourceAssembler)
    {OPTIONS [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: optionsForSearch(RootResourceInformation,String)
    {HEAD [/{repository}/search/{search}], produces [application/hal+json || application/json || application/prs.hal-forms+json]}: headForSearch(RootResourceInformation,String)
DEBUG RepositoryRestHandlerMapping - 27 mappings in org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping
DEBUG Mappings - 
    o.s.d.r.w.RepositorySchemaController:
    {GET [/profile/{repository}], produces [application/schema+json]}: schema(RootResourceInformation)
DEBUG Mappings - 
    o.s.d.r.w.a.AlpsController:
    {GET [/profile/{repository}], produces [application/alps+json || */*]}: descriptor(RootResourceInformation)
    {OPTIONS [/profile/{repository}], produces [application/alps+json]}: alpsOptions()
DEBUG Mappings - 
    o.s.d.r.w.ProfileController:
    {OPTIONS [/profile]}: profileOptions()
    {GET [/profile]}: listAllFormsOfMetadata()
curl -d "address1=410SouthMain&address2=&city=Romeo&state=MI&zip=78723" -X POST http://localhost:8080/validateAddress