Aspectj Installation and Configuration Guide

zhaozj2021-02-16  44

Quote

As the saying goes, workers are good, and must first make a tool. To learn AOP (aspect programming) and Aspectj must first know how to install and configure your development environment, this article will guide you how to get out of the study.

Aspectj installation and setting

Download the latest version of AspectJ from the AspectJ download page, you can decompress it into the specified directory after downloading. Then perform the following steps:

· Copy /lib/aspectjrt.jar file to / jre / lib / ext directory or add it to your ClassPath environment variable.

· Create a directory / bin and add it to the environment variable PATH, newly built two .bat files Ajc.bat and ajcbrowser.bat under the bin directory.

· Use /bin/java.exe -classpath

/lib/aspectjtools.jar - xmx64 org.aspectj.tools.ajc.main% * statement copy to the AJC.bat file, you can use Ajc.bat to compile the code for your AspectJ app, For example, AJC -Argfile Examples.lst.

• Copy /bin/java.exe -jar /lib/aspectjtools.jar% * Save in the AjcBrowser.bat file, you can compile the code using the aspectj graph browsing method, for example The command line is knocking into the AjcBrowser Examples.lst.

Figure 1: Aspectj graphic editing compilation window

Note: For your JDK installation directory, The file extension ".lst" is ".lst" file with ".lst" is a text file containing file path information for all Aspectj applications (must For the absolute path name, there is no space or wrap in the middle of the two path names).

Aspectj for JBuilder installation and settings for open tools

Aspectj for jbuilder is an open tool that supports JBuilder to use AspectJ, you can download its latest version in the AspectJ4JBuilder download page and uncompatched to the specified directory, then perform the following steps:

• Copy all .jar files under the "Aspectj for JBuilder Dir> / lib / EXT directory to the LIB / EXT directory of jbuilder. If you want to delete it, delete the three files in the LIB / EXT of JBuilder.

· Then start JBUIDER to find more than one option in the toolbar

: Figure 2: Toolbar of Aspectj for JBuilder

There are four icons in the figure in the figure "1", press the first to start the AspectJ browser, the second press will provide the function of navigation and class browsing, the third column is compiled, and finally A class that will be compiled after pressing the class in the ".lst" file.

Figure 3: Reservoir setting required by the project

Note: The Aspect rutime library must be added to the project's library, as shown in Figure 3. In addition, because the ASPECTJ's AJC compiler does not automatically search the engineering path, you need to add all the necessary ".lst" files to the current project so that the AJC compiler compiles all files, otherwise it is only compiled The class in the ".lst" file.

Open tool bug

From now on, there are tools for designing IDEs such as Eclipse, Emacs, NetBean. However, these tools or less bug, especially some projects, clearly using the command line AJC directly can succeed, but the AJC compiler in these integrated environments can not run, so if you are confident, you can't Compiling in the IDE, when you have some strange compilation errors, you can now compile, you may be able to compile. For example, an example of Observer, an AspectJ-110 version cannot be successfully compiled in the JBuilder ID, but can be successfully compiled successfully in the command line. Disclaimer This article is reserved by Starchu1981, if you need to pay, please write the author and source.

转载请注明原文地址:https://www.9cbs.com/read-26878.html

New Post(0)