GVKun编程网logo

spring boot ---Whitelabel Error Page

17

在本文中,我们将给您介绍关于springboot---WhitelabelErrorPage的详细内容,此外,我们还将为您提供关于IntelliJIDEA2017版spring-boot2.03后Pa

在本文中,我们将给您介绍关于spring boot ---Whitelabel Error Page的详细内容,此外,我们还将为您提供关于IntelliJ IDEA 2017版 spring-boot 2.03后 Pageable用法;Pageable用法,PageRequest过时,新用法;Pageable过时问题;、java – 如何在spring-boot中禁用ErrorPageFilter?、mybatis 使用 pagehelper-spring-boot-starter 与 pagehelper 的区别、org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.ListLabelsResponse的实例源码的知识。

本文目录一览:

spring boot ---Whitelabel Error Page

spring boot ---Whitelabel Error Page

想试一下 spring boot 的 hello world,可是出错了

错误:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon Oct 29 09:55:25 CST 2018
There was an unexpected error (type=Not Found, status=404).
No message available
 
 
404??访问资源没找到。怎么可能呢

 

经过网上搜索终于找到原因了,controller 必须在 spring boot 的启动程序的包或子包

 

 新建一个包 com.exammple.demo.controller

将 IndexController.java 移到 com.example.demo.controller 下

然后访问 http://localhost:8080/

 

 ok 啦

 

 

附上我找到的答案地址:https://blog.csdn.net/kmesky/article/details/80019993

 

 

 

IntelliJ IDEA 2017版 spring-boot 2.03后 Pageable用法;Pageable用法,PageRequest过时,新用法;Pageable过时问题;

IntelliJ IDEA 2017版 spring-boot 2.03后 Pageable用法;Pageable用法,PageRequest过时,新用法;Pageable过时问题;

1、旧版本Pageable用法:

      

但是会显示,这个版本已经过时,这时可以查看源码。

一般,一个方法过时,就会在其附近形成一个新的同名的但是其他用法的方法。按照这个理念,来找这个源码。很幸运,蒙对了,我们找到了如同的代码,如果你找了恭喜你,你跟我一样幸运。

那么,现在问题来了,这个方法要怎么用呢,刚开始我是直接调用。如图:

但这,明显不对,所以我注意观察,这个方法,我发现它是一个静态方法,也就是PageRequest,于是根据静定方法的调用,是直接方法名调用.

然后就调用了其,存在的方法.of系列

使用就如下图:

其实,很多问题,就是找答案,找规律,这就是理科,一个很好玩的科目,就当是一个数列游戏,答案和规律就是理科的小窍门,希望,对你有所帮助.

 

java – 如何在spring-boot中禁用ErrorPageFilter?

java – 如何在spring-boot中禁用ErrorPageFilter?

我正在创建一个应该在tomcat上运行的soap服务.
我正在为我的应用程序使用 spring-boot,类似于:
@Configuration
@EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class)
public class AppConfig {
}

我的webservice(示例):

@Component
@WebService
public class MyWebservice {

    @WebMethod
    @WebResult
    public String test() {
        throw new MyException();
    }
}

@WebFault
public class MyException extends Exception {
}

问题:无论何时在webservice类中引发异常,服务器上都会记录以下消息:

ErrorPageFilter: Cannot forward to error page for request
[/services/MyWebservice] as the response has already been committed.
As a result,the response may have the wrong status code. If your
application is running on WebSphere Application Server you may be able
to resolve this problem by setting
com.ibm.ws.webcontainer.invokeFlushAfterService to false

问题:我该如何防范?

解决方法

要在Spring Boot中禁用ErrorPageFilter(使用1.3.0.RELEASE进行测试),请将以下bean添加到Spring配置中:
@Bean
public ErrorPageFilter errorPageFilter() {
    return new ErrorPageFilter();
}

@Bean
public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    filterRegistrationBean.setFilter(filter);
    filterRegistrationBean.setEnabled(false);
    return filterRegistrationBean;
}

mybatis 使用 pagehelper-spring-boot-starter 与 pagehelper 的区别

mybatis 使用 pagehelper-spring-boot-starter 与 pagehelper 的区别

一、在使用 

pagehelper-spring-boot-starter时

在 pom.xml 引入

<!-- mybatis 分页 -->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.5</version>
</dependency>

在 application.yml 配置 分页插件信息

#mybatis 分页
pagehelper:
  helperDialect: oracle
  reasonable: true
  supportMethodsArguments: true
  params: count=countSql

新建一个分页封装工具

public class PageUtils {

    /**
     * 将分页信息封装到统一的接口
     * @param pageRequest
     * @param pageInfo
     * @return
     */
    public static PageResult getPageResult(QueryParams pageRequest, PageInfo<?> pageInfo) {
        PageResult pageResult = new PageResult();
        pageResult.setPageNum(pageInfo.getPageNum());
        pageResult.setPageSize(pageInfo.getPageSize());
        pageResult.setTotalSize(pageInfo.getTotal());
        pageResult.setTotalPages(pageInfo.getPages());
        pageResult.setContent(pageInfo.getList());
        return pageResult;
    }
}

在 service 使用分页插件

//queryParams.getPage() 页数,queryParams.getRows() 行数 
PageHelper.startPage(queryParams.getPage(),queryParams.getRows());
List<SysUser> list = sysUserMapper.listPage();
PageInfo<SysUser> pageInfo = new PageInfo<SysUser>(list);
PageResult pageResult = PageUtils.getPageResult(queryParams,pageInfo);

二、在使用 pagehelper  时

在 pom.xml 引入

<!-- mybatis分页-->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.1.4</version>
</dependency>

在 mybatisConfig.xml 加上

<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory"
      class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <!-- 自动扫描mapping.xml文件 -->
    <property name="mapperLocations" value="classpath:mapper/*.xml"></property>
    <property name="typeAliasesPackage" value="com.xxx.xxx.common.model"></property>
    <property name="plugins">
        <array>
            <bean class="com.github.pagehelper.PageInterceptor">
                <!-- 这里的几个配置主要演示如何使用,如果不理解,一定要去掉下面的配置 -->
                <property name="properties">
                    <value>
                        helperDialect=oracle
                        reasonable=true
                        supportMethodsArguments=true
                        params=count=countSql
                        autoRuntimeDialect=true
                    </value>
                </property>
            </bean>
        </array>
    </property>
    <!-- 配置mybatis配置文件的位置 -->
    <!--<property name="configLocation" value="classpath:mybatis-config.xml"/>-->
</bean>

工具类新建一个也是一样的就可以,调用方式一样,就是在不同的地方配置,一个是使用 spring boot 的自动配置,

一个是我们自己在 mybatisConfig.xm 自己配置。

org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.ListLabelsResponse的实例源码

org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.ListLabelsResponse的实例源码

项目:ditb    文件:TestVisibilityLabelsWithDefaultVisLabelService.java   
@Test
public void testListLabelsWithRegEx() throws Throwable {
  PrivilegedExceptionAction<ListLabelsResponse> action =
      new PrivilegedExceptionAction<ListLabelsResponse>() {
    public ListLabelsResponse run() throws Exception {
      ListLabelsResponse response = null;
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        response = VisibilityClient.listLabels(conn,".*secret");
      } catch (Throwable e) {
        fail("Should not have thrown exception");
      }
      // Only return the labels that end with 'secret'
      List<ByteString> labels = response.getLabelList();
      assertEquals(2,labels.size());
      assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes())));
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabelsWithDefaultVisLabelService.java   
@Test
public void testListLabelsWithRegEx() throws Throwable {
  PrivilegedExceptionAction<ListLabelsResponse> action =
      new PrivilegedExceptionAction<ListLabelsResponse>() {
    public ListLabelsResponse run() throws Exception {
      ListLabelsResponse response = null;
      try {
        response = VisibilityClient.listLabels(conf,labels.size());
      assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes())));
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestVisibilityLabelsWithDefaultVisLabelService.java   
@Test
public void testListLabelsWithRegEx() throws Throwable {
  PrivilegedExceptionAction<ListLabelsResponse> action =
      new PrivilegedExceptionAction<ListLabelsResponse>() {
    @Override
    public ListLabelsResponse run() throws Exception {
      ListLabelsResponse response = null;
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        response = VisibilityClient.listLabels(conn,labels.size());
      assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes())));
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:ditb    文件:TestVisibilityLabelsWithDefaultVisLabelService.java   
@Test
public void testListLabels() throws Throwable {
  PrivilegedExceptionAction<ListLabelsResponse> action =
      new PrivilegedExceptionAction<ListLabelsResponse>() {
    public ListLabelsResponse run() throws Exception {
      ListLabelsResponse response = null;
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        response = VisibilityClient.listLabels(conn,null);
      } catch (Throwable e) {
        fail("Should not have thrown exception");
      }
      // The addLabels() in setup added:
      // { SECRET,TOPSECRET,CONFIDENTIAL,PUBLIC,PRIVATE,copYRIGHT,ACCENT,//  UNICODE_VIS_TAG,UC1,UC2 };
      // The prevIoUs tests added 2 more labels: ABC,XYZ
      // The 'system' label is excluded.
      List<ByteString> labels = response.getLabelList();
      assertEquals(12,labels.size());
      assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(CONFIDENTIAL.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom("ABC".getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom("XYZ".getBytes())));
      assertFalse(labels.contains(ByteString.copyFrom(SYstem_LABEL.getBytes())));
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:pbase    文件:TestVisibilityLabelsWithDefaultVisLabelService.java   
@Test
public void testListLabels() throws Throwable {
  PrivilegedExceptionAction<ListLabelsResponse> action =
      new PrivilegedExceptionAction<ListLabelsResponse>() {
    public ListLabelsResponse run() throws Exception {
      ListLabelsResponse response = null;
      try {
        response = VisibilityClient.listLabels(conf,labels.size());
      assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(CONFIDENTIAL.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom("ABC".getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom("XYZ".getBytes())));
      assertFalse(labels.contains(ByteString.copyFrom(SYstem_LABEL.getBytes())));
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:TestVisibilityLabelsWithDefaultVisLabelService.java   
@Test
public void testListLabels() throws Throwable {
  PrivilegedExceptionAction<ListLabelsResponse> action =
      new PrivilegedExceptionAction<ListLabelsResponse>() {
    @Override
    public ListLabelsResponse run() throws Exception {
      ListLabelsResponse response = null;
      try (Connection conn = ConnectionFactory.createConnection(conf)) {
        response = VisibilityClient.listLabels(conn,labels.size());
      assertTrue(labels.contains(ByteString.copyFrom(SECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(TOPSECRET.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom(CONFIDENTIAL.getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom("ABC".getBytes())));
      assertTrue(labels.contains(ByteString.copyFrom("XYZ".getBytes())));
      assertFalse(labels.contains(ByteString.copyFrom(SYstem_LABEL.getBytes())));
      return null;
    }
  };
  SUPERUSER.runAs(action);
}
项目:hbase    文件:VisibilityClient.java   
/**
 * Retrieve the list of visibility labels defined in the system.
 * @param connection The Connection instance to use.
 * @param regex  The regular expression to filter which labels are returned.
 * @return labels The list of visibility labels defined in the system.
 * @throws Throwable
 */
public static ListLabelsResponse listLabels(Connection connection,final String regex)
    throws Throwable {
  try (Table table = connection.getTable(LABELS_TABLE_NAME)) {
    Batch.Call<VisibilityLabelsService,ListLabelsResponse> callable =
        new Batch.Call<VisibilityLabelsService,ListLabelsResponse>() {
      ServerRpcController controller = new ServerRpcController();
      coprocessorRpcUtils.BlockingRpcCallback<ListLabelsResponse> rpcCallback =
          new coprocessorRpcUtils.BlockingRpcCallback<>();

      @Override
      public ListLabelsResponse call(VisibilityLabelsService service) throws IOException {
        ListLabelsRequest.Builder listAuthLabelsReqBuilder = ListLabelsRequest.newBuilder();
        if (regex != null) {
          // Compile the regex here to catch any regex exception earlier.
          Pattern pattern = Pattern.compile(regex);
          listAuthLabelsReqBuilder.setRegex(pattern.toString());
        }
        service.listLabels(controller,listAuthLabelsReqBuilder.build(),rpcCallback);
        ListLabelsResponse response = rpcCallback.get();
        if (controller.FailedOnException()) {
          throw controller.getFailedOn();
        }
        return response;
      }
    };
    Map<byte[],ListLabelsResponse> result =
        table.coprocessorService(VisibilityLabelsService.class,HConstants.EMPTY_BYTE_ARRAY,callable);
    return result.values().iterator().next(); // There will be exactly one region for labels
    // table and so one entry in result Map.
  }
}
项目:ditb    文件:VisibilityClient.java   
/**
 * Retrieve the list of visibility labels defined in the system.
 * @param connection The Connection instance to use.
 * @param regex  The regular expression to filter which labels are returned.
 * @return labels The list of visibility labels defined in the system.
 * @throws Throwable
 */
public static ListLabelsResponse listLabels(Connection connection,final String regex)
    throws Throwable {
  Table table = null;
  try {
    table = connection.getTable(LABELS_TABLE_NAME);
    Batch.Call<VisibilityLabelsService,ListLabelsResponse>() {
          ServerRpcController controller = new ServerRpcController();
          BlockingRpcCallback<ListLabelsResponse> rpcCallback =
              new BlockingRpcCallback<ListLabelsResponse>();

          public ListLabelsResponse call(VisibilityLabelsService service) throws IOException {
            ListLabelsRequest.Builder listAuthLabelsReqBuilder = ListLabelsRequest.newBuilder();
            if (regex != null) {
              // Compile the regex here to catch any regex exception earlier.
              Pattern pattern = Pattern.compile(regex);
              listAuthLabelsReqBuilder.setRegex(pattern.toString());
            }
            service.listLabels(controller,rpcCallback);
            ListLabelsResponse response = rpcCallback.get();
            if (controller.FailedOnException()) {
              throw controller.getFailedOn();
            }
            return response;
          }
        };
    Map<byte[],callable);
    return result.values().iterator().next(); // There will be exactly one region for labels
    // table and so one entry in result Map.
  }
  finally {
    if (table != null) {
      table.close();
    }
    if (connection != null) {
      connection.close();
    }
  }
}
项目:pbase    文件:VisibilityClient.java   
/**
 * Retrieve the list of visibility labels defined in the system.
 * @param conf
 * @param regex  The regular expression to filter which labels are returned.
 * @return labels The list of visibility labels defined in the system.
 * @throws Throwable
 */
public static ListLabelsResponse listLabels(Configuration conf,final String regex)
    throws Throwable {
  Connection connection = null;
  Table table = null;
  try {
    connection = ConnectionFactory.createConnection(conf);
    table = connection.getTable(LABELS_TABLE_NAME);
    Batch.Call<VisibilityLabelsService,ListLabelsResponse>() {
      ServerRpcController controller = new ServerRpcController();
      BlockingRpcCallback<ListLabelsResponse> rpcCallback =
          new BlockingRpcCallback<ListLabelsResponse>();

      public ListLabelsResponse call(VisibilityLabelsService service) throws IOException {
        ListLabelsRequest.Builder listAuthLabelsReqBuilder = ListLabelsRequest.newBuilder();
        if (regex != null) {
          // Compile the regex here to catch any regex exception earlier.
          Pattern pattern = Pattern.compile(regex);
          listAuthLabelsReqBuilder.setRegex(pattern.toString());
        }
        service.listLabels(controller,callable);
    return result.values().iterator().next(); // There will be exactly one region for labels
    // table and so one entry in result Map.
  }
  finally {
    if (table != null) {
      table.close();
    }
    if (connection != null) {
      connection.close();
    }
  }
}
项目:hbase    文件:TestMastercoprocessorServices.java   
@Override
public void listLabels(RpcController controller,ListLabelsRequest request,RpcCallback<ListLabelsResponse> done) {
}
项目:ditb    文件:VisibilityClient.java   
/**
 * Retrieve the list of visibility labels defined in the system.
 * @param conf
 * @param regex  The regular expression to filter which labels are returned.
 * @return labels The list of visibility labels defined in the system.
 * @throws Throwable
 * @deprecated Use {@link #listLabels(Connection,String)} instead.
 */
@Deprecated
public static ListLabelsResponse listLabels(Configuration conf,final String regex)
    throws Throwable {
  try(Connection connection = ConnectionFactory.createConnection(conf)){
    return listLabels(connection,regex);
  }
}
项目:hbase    文件:VisibilityClient.java   
/**
 * Retrieve the list of visibility labels defined in the system.
 * @param conf
 * @param regex  The regular expression to filter which labels are returned.
 * @return labels The list of visibility labels defined in the system.
 * @throws Throwable
 * @deprecated Use {@link #listLabels(Connection,regex);
  }
}

关于spring boot ---Whitelabel Error Page的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于IntelliJ IDEA 2017版 spring-boot 2.03后 Pageable用法;Pageable用法,PageRequest过时,新用法;Pageable过时问题;、java – 如何在spring-boot中禁用ErrorPageFilter?、mybatis 使用 pagehelper-spring-boot-starter 与 pagehelper 的区别、org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.ListLabelsResponse的实例源码等相关知识的信息别忘了在本站进行查找喔。

本文标签: