Category Archives: How to Fix

spring boot-beans in application context form a cycle

  Spring’s bean generation cycle conflicts, as shown in the following figure:

To exclude some configurations

@SpringBootApplication(exclude = {RedisAutoConfiguration.class,DataSourceAutoConfiguration.class, XADataSourceAutoConfiguration.class,
         JdbcTemplateAutoConfiguration.class})

[MacOS] brew install 404:Bottle missing, falling back to the default domain…

Contents of articles

Problem description solution

Problem description

MacOS version: 10.15.7 prompts that there is no WGet, so install it through brew. After installing brew, configure the domestic source brew install WGet and report an error

Solution

The homebrew address described in [homebrew boxes source help] is:
0 https://mirrors.ustc.edu.cn/homebrew-bottles/ Run brew config to see

HOMEBREW_BOTTLE_DOMAIN: https://mirrors.ustc.edu.cn/homebrew-bottles

The solution is to change the environment variables and change homebrew_ BOTTLE_ Correct domain

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zshrc

source ~/.zshrc

When idea writes JavaWeb, it can’t find servlet

When writing JSP, always worry about finding the location of servlet accurately
if the vallue of the servlet = (“/ myservlet”)
then use action = & lt;%= request.getContextPath()%>/ “Myservlet”, isn’t it very convenient

getcontextpath() is to find the project publishing path, that is, the root directory, while servlet value =/myservlet " represents that the servlet is in the root directory, so directly & lt;%= request.getContextPath()%>/ Myservlet can find the servlet. Similarly,
If value =/my/servlet "
then & lt;%= request.getContextPath()%>/ My/servlet is OK

java.util.Collections.max() [How to Use]

Description

max(Collection<? extends T>)   Method is used to return the largest element of a given set according to the natural order of its elements.

Manifesto

The following is the declaration of the Java. Util. Collections. Max () method.

public static <T extends Object & Comparable<?super T>> T max(Collection<?extends T> coll)

Parameters

coll  – The set whose largest element is to be determined.

Return value

Method call returns the largest element of a given collection, according to the natural order of its elements.

Exception

ClassCastException  – This exception is thrown if the collection contains elements that are not comparable to each other, such as strings and integers. NoSuchElementException  – If the collection is empty, this exception is thrown.

example

The following example shows the usage of Java. Util. Collections. Max()

import java.util.*;

public class CollectionsDemo {
   public static void main(String args[]) { 
      
      // create link list object 
      LinkedList<Integer> list = new LinkedList<Integer>();

      // populate the list  
      list.add(-18);  
      list.add(40);  
      list.add(-45);  
      list.add(12); 

      System.out.println("Max value is: " + Collections.max(list));          
   }  
}

Let’s compile and run the above program, which will produce the following result.

Max value is: 40

[Solved] ERROR Failed to compile with 3 errors These dependencies were not found: * pdfjs-dist/es5/buil

introduction

Xiao Fang is a junior student. Today, he joined a front-end intern position in a company. He is so proud that he plans to do a big job. Results the card was stuck in NPM run build , and the error message was reported (as follows).

$ npm run build

> [email protected] build /usr/local/docker/gitlab-ee-12.4.1/builds/63s9Rzjq/0/dev_web/system
> vue-cli-service build --mode production


-  Building for production...
 ERROR  Failed to compile with 3 errors PM 3:24:46

These dependencies were not found:

* pdfjs-dist/es5/build/pdf.js in ./node_modules/[email protected]@cache-loader/dist/cjs.js??ref--12-0!./node_modules/[email protected]@thread-loader/dist/cjs.js!./node_modules/[email protected]@babel-loader/lib!./node_modules/[email protected]@cache-loader/dist/cjs.js??ref--0-0!./node_modules/[email protected]@vue-loader/lib??vue-loader-options!./node_modules/[email protected]@vue-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js&
* worker-loader!pdfjs-dist/es5/build/pdf.worker.js in ./node_modules/[email protected]@cache-loader/dist/cjs.js??ref--12-0!./node_modules/[email protected]@thread-loader/dist/cjs.js!./node_modules/[email protected]@babel-loader/lib!./node_modules/[email protected]@cache-loader/dist/cjs.js??ref--0-0!./node_modules/[email protected]@vue-loader/lib??vue-loader-options!./node_modules/[email protected]@vue-pdf/src/vuePdfNoSss.vue?vue&type=script&lang=js&
* pdfjs-dist/es5/web/pdf_viewer in ./node_modules/[email protected]@vue-pdf/src/pdfjsWrapper.js

To install them, you can run: npm install --save pdfjs-dist/es5/build/pdf.js worker-loader!pdfjs-dist/es5/build/pdf.worker.js pdfjs-dist/es5/web/pdf_viewer
 ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `vue-cli-service build --mode production`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-06-08T07_24_46_457Z-debug.log
ERROR: Job failed: exit status 1

What? Can’t even run the project, so you have to be dissuaded on the first day of employment?! Reluctantly, he spent a whole day searching Baidu and Google, but he didn’t find the problem

After the meeting in the afternoon, the leader passed by his work station and saw Xiao Fang, who was in a mess, asked if the environment had been set up. At this time, Xiao Fang was already suffering from this problem and fed it back to the leaders. Unexpectedly, the leader gently put down the water cup in his hand and did a careful investigation on Xiao Fang’s work position. The leader quickly located the node_ However, it seems that this problem is rather intractable, and it has not been solved after half an hour. In the end, the leader put the node in his computer_ Moudels is copied, and the problem is found after replacement

it can be seen vaguely that Xiaofang installed the 2.8.335 version of pdfjs dist, while the leader used 2.5.207 , and this newer version is not compatible with the node environment, resulting in an error.

solve

The problem is that in the development team, the front-end project should not put the package lock. JSON file used to lock the version into gitignore, because the most critical factor of development is stability rather than the latest
hope to solve your problem, see you~

[Solved] Docker ubuntu swoole fatal error: openssl/ssl.h: No such file or directory

Dockerfile

RUN apt-get update -y
RUN apt-get install -y libssl-dev
RUN cd /tmp/ && rm -rf ./swoole-src
&& curl -o ./swoole.tar.gz https://github.com/swoole/swoole-src/archive/master.tar.gz -L
&& tar zxvf ./swoole.tar.gz
&& mv swoole-src* swoole-src
&& cd swoole-src
&& phpize
&& ./configure –enable-openssl –with-openssl-dir=/usr/lib/ssl –enable-http2
&& make && make install
&& docker-php-ext-enable swoole

Although openssl has been installed, but the corresponding libs are missing, looking for half a day to know the need to install libssl-dev (centos is openssl-devel)

openssl version -a

Android’s viewpager slides to determine whether the current stop page is the last page

Step 1: write several global variables to record:

   /**
     * Record if the sliding page is the last page
     */
    private boolean isHomeLastPage = false;
    private boolean isHomeDragPage = false;

The second step is to get the last element by implementing the listening onpageselected() in VP

@Override
	     public void onPageSelected(int position) {
	            super.onPageSelected(position);
	
	            Log.e("videoPositionposition", position + "");
	            //get the last page/position equals the last element
	            isHomeLastPage = position == datas.size() - 1;
	      }

The third step is to implement the listening onpagescrollstatechanged() in VP to determine whether the current sliding state is in,

   @Override
            public void onPageScrollStateChanged(int state) {
                // 0: do nothing 1: start sliding 2: end sliding Scrolling listener
                isHomeDragPage = state == ViewPager2.SCROLL_STATE_DRAGGING;
                //judge that the last one will not be loaded
            }

The fourth step is to implement onpagescrolled() 1.
1. Judge whether it is the last element
2. Whether it is in sliding state,
3. The offset of posionoffsetpixels is 0.
the work is done, and the judgment of VP sliding to the last page has been done

 @Override
 public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

       //Determine the last element and slide state, and the offset is 0
       Log.e("vp2CCC", "vp2CCC" + isHomeLastPage + " " + isHomeDragPage + " " + positionOffsetPixels);
       if (isHomeLastPage && isHomeDragPage && positionOffsetPixels == 0) { //the current page is the last page and is dragging and the pixel offset is 0
           Toast.makeText(getActivity(), "The current page is the last page", Toast.LENGTH_SHORT).show();
       } else {
       }
   }