Tag Archives: interface

Error:Abnormal build process termination [How to Solve]

Pre:

Today I close the Firewall and java program failed to start error:

Error:Abnormal build process termination:
“C:\Program Files\Java\jdk1.8.0_152\bin\java.exe” -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=“” -Djdt.compiler.useSingleThread=true -Dpreload.project.path=D:/tangyuzhongshowtime/springboot-mybatis-token-freemarker -Dpreload.config.path=C:/Users/Administrator/AppData/Roaming/JetBrains/IntelliJIdea2020.1/options -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Dio.netty.initialSeedUniquifier=1508232679689852792 -Dfile.encoding=GBK -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IntelliJIdea2020.1 “-Didea.home.path=D:\Idea\IntelliJ IDEA 2020.1.2” -Didea.config.path=C:\Users\Administrator\AppData\Roaming\JetBrains\IntelliJIdea2020.1 -Didea.plugins.path=C:\Users\Administrator\AppData\Roaming\JetBrains\IntelliJIdea2020.1\plugins -Djps.log.dir=C:/Users/Administrator/AppData/Local/JetBrains/IntelliJIdea2020.1/log/build-log “-Djps.fallback.jdk.home=D:/Idea/IntelliJ IDEA 2020.1.2/jbr” -Djps.fallback.jdk.version=11.0.7 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/Administrator/AppData/Local/JetBrains/IntelliJIdea2020.1/compile-server/springboot-mybatis-token-freemarker_830f3c4b/temp -Djps.backward.ref.index.builder=true -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=“C:\Users\ADMINI~1\AppData\Local\Temp\kotlin-idea-1545321366046478132-is-running” -classpath “D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_152/lib/tools.jar” org.jetbrains.jps.cmdline.Launcher “D:/Idea/IntelliJ IDEA 2020.1.2/lib/commons-lang3-3.9.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-impl-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/gson-2.8.6.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/trove4j.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/commons-logging-1.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/asm-all-7.0.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-transport-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-api-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/plexus-interpolation-1.25.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-repository-metadata-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/slf4j-api-1.7.25.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/nanoxml-2.2.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-provider-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-model-builder-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/platform-api.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/forms-1.1-preview.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-buffer-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/oro-2.0.8.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/resources_en.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/plexus-utils-3.2.0.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/util.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/qdox-2.0-M10.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/lz4-java-1.7.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/plexus-component-annotations-1.7.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-builder-support-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/javac2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/log4j.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-model-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/jna-platform.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/jps-builders.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-common-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/guava-28.2-jre.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-codec-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/aether-dependency-resolver.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/idea_rt.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-artifact-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-util-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-spi-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/jps-builders-6.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-resolver-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/jdom.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/httpcore-4.4.13.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/annotations.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/protobuf-java-3.5.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/maven-resolver-transport-http-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/jna.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/jps-model.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/httpclient-4.5.12.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/JavaEE/lib/jasper-v2-rt.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/gson-2.8.6.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/jarutils.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/guava-28.2-jre.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/common-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/gradle/lib/gradle-api-6.1.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/gson-2.8.6.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/jarutils.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/guava-28.2-jre.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/common-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/gradle/lib/gradle-api-6.1.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/IntelliLang/lib/intellilang-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/eclipse/lib/eclipse-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/eclipse/lib/common-eclipse-util.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/ant/lib/ant-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Groovy/lib/groovy-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Groovy/lib/groovy-rt-constants.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/maven/lib/maven-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/osmorc-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/biz.aQute.bndlib-5.0.0.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/biz.aQute.repository-5.0.0.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/biz.aQute.resolve-5.0.0.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/bundlor-all.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/aspectj/lib/aspectj-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/gradle-java/lib/gradle-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/javaFX/lib/javaFX-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/javaFX/lib/common-javaFX-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/uiDesigner/lib/jps/ui-designer-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/devkit/lib/devkit-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/flex/lib/flex-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/flex/lib/flex-shared.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/JavaEE/lib/javaee-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/JavaEE/lib/jps/jpa-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Kotlin/lib/kotlin-stdlib.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Kotlin/lib/kotlin-reflect.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Kotlin/lib/kotlin-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/jps/android-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/android-common.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/build-common.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/android-rt.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/android-extensions-ide.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/sdk-common-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/common-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/repository-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/sdklib-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/jarutils.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/layoutlib-api-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/manifest-merger-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/webSphereIntegration/lib/jps/webSphere-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/weblogicIntegration/lib/jps/weblogic-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/dmServer/lib/dmServer-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/GwtStudio/lib/gwt-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Grails/lib/grails-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Grails/lib/grails-compiler-patch.jar” org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 49464 1fa79df5-132b-4c83-a797-a493feea0e28 C:/Users/Administrator/AppData/Local/JetBrains/IntelliJIdea2020.1/compile-server
Build process started. Classpath: D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_152/lib/tools.jarSLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementationSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Error connecting to 127.0.0.1:49464; reason: Connection timed out: no further information: /127.0.0.1:49464
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection timed out: no further information: /127.0.0.1:49464
Caused by: java.net.ConnectException: Connection timed out: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at java.lang.Thread.run(Thread.java:748)
Exiting.

Solution:

Close the WIndows Firewall

If this method above does not work. try:

re-add the jdk of sdk in project structure.

[Solved] Annotation Customize Error: ElementType cannot be resolved to a variable

In the development process, you may use custom annotations (this article uses custom annotations when using JWT) to report an error:

ElementType cannot be resolved to a variable

Manually import packages:

import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.ElementType;

Perfect solution

Aspecj cannot intercept method annotations on an interface

Aspecj cannot intercept method annotations on an interface

Aspecj can’t intercept the method annotation on the interface, it can only act on the method of the implementation class. At this time, it needs to use methodinterceptor to implement.

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface AopTest {
}

Interface

public interface TestAOPI {
    @AopTest
    public String test();

}

Implementation class 1

@Service
public class TestAOPService implements TestAOPI{
    @Override
    public String test() {
        return "service";
    }
}

Implementation class 2

@Service
public class TestAOPService2 implements TestAOPI{
	@AopTest
    @Override
    public String test() {
        return "service";
    }
}

Aspecj (partially valid)

If and only if the @ aoptest annotation is added to the method of the implementation class, it will take effect (implementation class 2), but implementation class 1 will not

@Aspect
@Configuration
public class AopTestAspect {
  /**
     * Identifies the method annotated with OperationLog
     */
    @Pointcut("@annotation(com.example.demo1.config.AopTest)")
    public void methodHasAopTestAnnotation() {
    }
    
    @Around("methodHasAopTestAnnotation()")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("aop!!!");
        return joinPoint.proceed();
    }
}

Solution

It needs to be changed to the following way by manual

@Configuration
public class AopTestConfiguration {
	@Bean
    public Advisor methodPointcutAdvisor() {
        AopTestMethodPointcutAdvisor advisor = new AopTestMethodPointcutAdvisor();
        advisor.setAdvice(new AopTestInterceptor());
        return advisor;
    }

    class AopTestInterceptor implements MethodInterceptor {
        @Override
        public Object invoke(MethodInvocation invocation) throws Throwable {
            String name = invocation.getMethod().getName();
            System.out.println("==============" + name + " before ================");
            Object result = invocation.proceed();
            System.out.println("==============" + name + " after ================");
            return result;
        }
    }
    public class AopTestMethodPointcutAdvisor extends StaticMethodMatcherPointcutAdvisor {
        @Override
        public boolean matches(Method method, Class<?> targetClass) {
        	// Implementing a class method with a target annotation on it
            if(method.isAnnotationPresent(AopTest.class)){
                return true;
            }
            // The method has a corresponding interface method and the interface method is annotated
            Class<?>[] interfaces = method.getDeclaringClass().getInterfaces();
            for (int i = 0; i < interfaces.length; i++) {
                Method[] methods = interfaces[i].getMethods();
                for (int j = 0; j < methods.length; j++) {
                    if(methods[j].getName().equals(method.getName())){
                        return methods[j].isAnnotationPresent(AopTest.class);
                    }
                }
            }
            return false;
        }
    }
}

The tree component in easyUI does not display data or displays undefined solutions

In recent days, I have learned easyUI and used the tree component. After n days of pain, I finally came out. Now I will summarize some problems.

1. In the official demo, all the data is taken from the. JSON file. In practical application, it is obviously impossible to do so. If you want to take it from the database, then the problem is, how to get it?There’s no explanation in the official demo, and I haven’t found any results after searching online for a long time

Methods 1:Ajax is fetched, after the web interface is loaded, the Ajax is called, and the value is spliced from the background in the database, and spliced into JSON. There are many methods of splicing. Here is not enumerated. After the completion of the mosaic, JSON is written back by response writer. In JS, the data parameter of tree is the returned JSON (time reason, this method is not tested, and the theory is feasible).

Method 2: root method 1 is similar: the following is the code

HTML code of tree:

<ul id="department_tree" class="easyui-tree"></ul>

JS code of tree:

/**
 * @argument Fetching data from a tree by URL
 * @author ZHENGWEI
 * @date 2015-5-8
 * @version 1.0
 */
$(document).ready(function(){
	/* Called when loading is complete*/
	$("#department_tree").tree({
		/*JSON spliced address*/
		url:'CompanyStaffAction!listCompanyDepartment.action',
		/*Linked lines*/
		lines:true,
		/*animation effect*/
		animate:true
	});
})

The URL is the action returned to JSON in the background, and the code is as follows

/**
	 * Search company's department information
	 * @author ZHENGWEI
	 * @throws JSONException 
	 * @throws IOException 
	 * @date 2015-5-7
	 */
	public String listCompanyDepartment() throws JSONException, IOException{
		//Set the encoding format to prevent Chinese characters from being garbled
		response.setCharacterEncoding("UTF-8");
		//return company department information
		List<CompanyDepartmentInfo> companyDepartmentInfoList = this.companyStaffService.listCompanyDepartment();
		// Declare the JSONArray object and build the tree
		JSONArray jsonChildTreeArray = new JSONArray();
		//condemn empty
		if(companyDepartmentInfoList.size() != 0){
			for(CompanyDepartmentInfo companyDepartmentInfo:companyDepartmentInfoList){
				JSONObject jsonChildInfoObject = new JSONObject();
				jsonChildInfoObject.put("id", '"'+companyDepartmentInfo.getDepartmentId()+'"');
				jsonChildInfoObject.put("text", companyDepartmentInfo.getDepartmentName());
				jsonChildTreeArray.put(jsonChildInfoObject);
			}
		}
		JSONObject jsonDepartmentTree = new JSONObject();
		jsonDepartmentTree.put("id", "0");
		jsonDepartmentTree.put("text", "CompanyDepartmentTree");
		jsonDepartmentTree.put("state", "open");
		// turn the jsonChildTreeArray into a child node
		jsonDepartmentTree.put("children", jsonChildTreeArray);
		//string type, add '[]' to JSON
		String treeData = jsonDepartmentTree.toString();
		treeData = "["+treeData+"]";
		// Declare PrintWriter variable to pass back JSON
		PrintWriter out = response.getWriter();
		out.write(treeData);
		return null;
	}

It must be noted that,

After the encapsulation of JSON, make sure to print it to see if there is a [] symbol package outside of JSON, otherwise tree can’t read the data!!!!

The final results are as follows:

 

 

It’s a very hard process… It’s tears when I talk too much, and many problems on the Internet can’t reach the point. I’ve thought about it for many days, and I hope that students who study in the future will avoid detours

Local refresh of listview and GridView

As we all know, listview and GridView refresh the interface by calling adapter.notifyDataSetChanged () refresh the interface. But this method has its disadvantages. It refreshes all the data in the interface, no matter whether the data has changed or not. If listview loads a lot of data (e.g. 100 entries)

When refreshing, it will cause a lot of system overhead. How to refresh only one like QQ space personal dynamic

Main principles:
refresh an item in listview
1. Get the current index position and data of the item to be refreshed
2. Reset the acquired data
3. Put the reset data in the original position of the data set in the adapter (refresh a piece of data in the original data set according to the position)
4. Get the view of the sub item to be refreshed in listview
5. Get new data from the updated data set and update the data in viwe (operate in handler to refresh the interface)

The functions are as follows, with detailed comments in the code:

public class MainActivity extends Activity  
{  

    private ArrayList<MyListItem> list = null;  
    private ListView              lv;  
    private MyListAdapter         adapter;  

    @Override  
    protected void onCreate(Bundle savedInstanceState)  
    {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        intitData();  
        lv = (ListView) findViewById(R.id.listView1);  
        adapter = new MyListAdapter(list, getApplicationContext());  
        adapter.setListView(lv);  
        lv.setAdapter(adapter);  

        lv.setOnItemClickListener(new OnItemClickListener()  
        {  

            @Override  
            public void onItemClick(AdapterView<?> parent, View view, int position, long id)  
            {  
                // Get the data of the clicked item in the listview   
                MyListItem item = (MyListItem) parent.getItemAtPosition(position);  
                Log.i("eee", item.getData() + " == " + item.getPosition());  
                // Update data  
                item.setData("update item " + position);  
                // Update Interface  
                adapter.updateItemData(item);  
            }  
        });  

    }  

    /** 
     * Initialization data 
     */  
    private void intitData()  
    {  
        list = new ArrayList<MyListItem>();  
        for (int i = 0; i < 20; i++)  
        {  
            MyListItem item = new MyListItem();  
            item.setData("item " + i);  
            item.setPosition(i);  
            list.add(item);  
        }  
    }  

    /** 
     * Customize item data type 
     */  
    class MyListItem  
    {  
        /** 
         * data id 
         */  
        private int    dataId;  
        /** 
         * datas 
         */  
        private String data;  

        public int getPosition()  
        {  
            return dataId;  
        }  

        public void setPosition(int position)  
        {  
            this.dataId = position;  
        }  

        public String getData()  
        {  
            return data;  
        }  

        public void setData(String data)  
        {  
            this.data = data;  
        }  

    }  
}  
activity to call, the function operation is mainly encapsulated in the adapter as follows.

public class MyListAdapter extends BaseAdapter  
{  

    /** 
     * Data sets in listview 
     */  
    private ArrayList<MyListItem> mDataList;  

    private Context               mContext;  
    private ListView              mListView;  

    public MyListAdapter(ArrayList<MyListItem> list, Context cont)  
    {  
        this.mDataList = list;  
        this.mContext = cont;  
    }  

    /** 
     * Set the listview object 
     *  
     * @param lisv 
     */  
    public void setListView(ListView lisv)  
    {  
        this.mListView = lisv;  
    }  

    /** 
     * update listview Single data 
     *  
     * @param item New data object 
     */  
    public void updateItemData(MyListItem item)  
    {  
        Message msg = Message.obtain();  
        int ids = -1;  
        // Compare data to get the position of the corresponding data in the list  
        for (int i = 0; i < mDataList.size(); i++)  
        {  
            if (mDataList.get(i).getPosition() == item.getPosition())  
            {  
                ids = i;  
            }  
        }  
        msg.arg1 = ids;  
        // Update the data in the corresponding position of mDataList  
        mDataList.set(ids, item);  
        // handle refreshes the interface  
        han.sendMessage(msg);  
    }  

    @SuppressLint("HandlerLeak")  
    private Handler han = new Handler()  
                        {  
                            public void handleMessage(android.os.Message msg)  
                            {  
                                updateItem(msg.arg1);  
                            };  
                        };  

    /** 
     * Refresh the specified item 
     *  
     * @param index item's position in listview 
     */  
    private void updateItem(int index)  
    {  
        if (mListView == null)  
        {  
            return;  
        }  

        // Get the currently visible position of the item  
        int visiblePosition = mListView.getFirstVisiblePosition();  
        // If you add headerview, firstview is hearderview  
        // All indexes + 1 to get the first view  
        // View view = listview.getChildAt(index - visiblePosition + 1);  
        // Get the clicked view  
        View view = mListView.getChildAt(index - visiblePosition);  
        TextView txt = (TextView) view.findViewById(R.id.textView1);  
        // get mDataList.set(ids, item); the updated data  
        MyListItem data = (MyListItem) getItem(index);  
        // Reset the interface to display data  
        txt.setText(data.getData());  
    }  

    @Override  
    public int getCount()  
    {  
        // TODO Auto-generated method stub  
        return mDataList.size();  
    }  

    @Override  
    public Object getItem(int position)  
    {  
        // TODO Auto-generated method stub  
        return mDataList.get(position);  
    }  

    @Override  
    public long getItemId(int position)  
    {  
        // TODO Auto-generated method stub  
        return position;  
    }  

    @Override  
    public View getView(int position, View convertView, ViewGroup parent)  
    {  
        // TODO Auto-generated method stub  
        if (convertView == null)  
        {  
            convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item, null);  
        }  
        TextView txt = (TextView) convertView.findViewById(R.id.textView1);  
        txt.setText(mDataList.get(position).getData());  
        return convertView;  
    }  

}  

No matter how far and hard the road ahead is, as long as the direction is right, no matter how rugged, it is closer to happiness than standing in the same place!

Servlet error: no interface expected here

No interface expected here error was encountered when implementing the code. Idea was not compiled. No interface expected here means there is no interface.

resolvent

After a look around, we found that servlet is an interface, not a class. Httpservlet is an abstract class, so when we change it to servlet, we need to change extensions to implements.

Change extend to implements

 

 

 

Network card problem: Unable to initialize Windows Sockets interface

Yesterday, I had a problem with a computer in my company, which could not surf the Internet and could be Shared on Windows. Using the Ping gateway in the command window and 127.0.0.1 both showed the same results
Unable to initialize Windows Sockets interface, error code 0.
Other network Settings are normal, and there are unusually long waits in the “network connection” area when you log in to Windows.
search on the Internet to know that this is a configuration or other software caused by the improper use of Windows system file is destroyed, download winsockfix.exe run to solve the problem
The above method cannot be used for Win2003. Later, I found a method on the Microsoft website. However, this method is manual repair, which I have not tested:
1. Backup and delete winsock. DLL Wsock. DLL under % Winroot % System32
2. Backup, delete the registry key HKEY_LOCAL_MACHINE/System/CurrentControlSet/Services/Winsock2
3. Delete the TCP/IP protocol and then uninstall the network card
4. Reinstall the network card and TCP/IP protocol.
Microsoft has a solution for http://support.microsoft.com/kb/288133/en-us

How to Fix nbconvert failed: Pandoc wasn’t found. Please check that pandoc is installed:

when you want to convert your Jupyte Notebook to PDF, this can appear:

solution:

1 download pandoc library and install, download address: http://pandoc.org/installing.html#windows

ps: domestic didn’t over the wall of friends may not be able to download or slow download speed, CSDN download address: http://download.csdn.net/download/weixin_37029453/10161639

2 download and install MikTeX

3 in Jupyter to PDF operation, as shown in the picture:


after the system will pop up the interface to let you install some toolkits, continue to click the installation, installation is done!

> /strong>

Abstract method and static method of java interface

introduction

before JDK1.8, interface did not provide any concrete implementation. It was described in JAVA programming ideas as follows: “interface is a keyword that produces a completely abstract class. It does not provide any concrete implementation at all. It allows the author to determine the method name, argument list, and return type, but does not have any method body. The interface provides the form, not any concrete implementation.

but this limitation is broken in JDK1.8, where interfaces allow you to define default methods and static methods.

code example

defines an IHello interface

public interface IHello {
	//抽象方法
	void sayHi();
	//静态方法
	static void sayHello() {
		System.out.println("static method : say Hello!");
	}
	//默认方法
	default void sayByebye() {
		System.out.println("default method : say bye!");
	}

}

defines an IHello interface implementation class

public class HelloImpl implements IHello {
	//实现抽象方法
	@Override
	public void sayHi() {
		
		System.out.println("normal method:say hi");
		
	}
}

The

method call

public class App 
{
	public static void main(String[] args)
    {
    	HelloImpl helloImpl = new HelloImpl();
    	//对于abstract抽象方法通过实例对象来调用
    	helloImpl.sayHi();
    	//default 方法只能通过实例对象来调用
    	helloImpl.sayByebye();
    	//静态方法通过 接口名.方法名()来调用
    	IHello.sayHello();
    	
    	//接口是不允许new的,如果使用new后面必须跟上一对花括号用于实现抽象方法,这种方式被称为匿名实现类,匿名实现类是一种没有名称的实现类
    	//匿名实现类的好处:不用再单独声明一个类 缺点:由于没有名称。不能重复使用,只能使用一次
    	new IHello() {			
			@Override
			public void sayHi() {
				System.out.println("normal method;say hi 新定义");			
			}
		}.sayHi();
    }
}

normal method: say hi
default method: say bye!> static method: say Hello!
normal method: say hi new definition