Appfuse is an integrated framework for developing Web application systems using the Java language. The biggest headache for Java developers is that they don't know how to choose a lot of frameworks. The performance of these frameworks, how compatibility, and so on, require filtering comparisons. Appfuse author Matt Raible has done an in-depth study of these frameworks, bringing the best parts of these frameworks together to form the best integration framework. The latest stable version of this framework is now 3.5.
Basic framework in Appfuse:
- Bootstrap and jquery
- Maven, Hibernate, Spring and spring Security
- Java 7, Annotations, JSP 2.1, Servlet 3.0
- Web framework: GWT, JSF, Struts 2, Spring MVC, Tapestry 5, Wicket
- Jpa
Appfuse provides out-of-the-box functionality for many applications, including:
- Authentication and authorization
- User Management
- Remember Me (save login information, do not have to log in every time)
- Password hint
- Registration and Registration
- SSL switching
- Email
- Extension-less URLs (do not know how to translate, help!!!) )
- File Upload
- Generating a crud back end
- Full support for Eclipse, idea and NetBeans
- Quickly launch and deploy with plugins such as Maven and jetty
- Multi-mode options (profiles) with cargo and MAVEN support multiple foreground applications and multiple database selection deployments, and can be tested
The latest appfuse and maven relationships are tight. Almost all operations are performed through MAVEN, so there is some understanding of MAVEN and modular development, a deeper understanding of MAVEN profiles, and a certain understanding of MAVEN's warehouse structure.
Appfuse supports multiple databases (Derby, H2, HSQLDB, MySQL, Oracle, PostgreSQL, SQL Server), and the default database is MySQL. When I switched to the Oracle database, I found a problem, and I had this article. Here I describe the problems and solutions found.
1. First download and install Maven 3.1.0+, there are a lot of tutorials online, here is not to repeat. Of course, you also need jdk7+, MySQL 5.5+.
2. Use Maven to generate an empty project that contains the Appfuse framework:
MVN archetype:generate-b-darchetypegroupid=org.appfuse.archetypes-darchetypeartifactid= Appfuse-modular-spring-archetype-darchetypeversion=3.5.0-dgroupid=com.mycompany.myproject-dartifactid= Myproject-darchetyperepository=https://oss.sonatype.org/content/repositories/appfuse
First explain this: this is a command to generate the MVN (archetype:generate) framework code, which will be used later. Where MyCompany is the company name and MyProject is the project name. The Appfuse version is 3.5.0. The most critical part is that Appfuse-modular-spring-archetype,modular represents multiple modules, and spring represents the front frame as spring MVC.
Start the command line (CMD). Modify the current directory to Java workspace (the directory where you want to place the code). Enter a large list of characters that begin with MVN, carriage return. Some jar packages may not be able to find the source because of the reasons that are well known in the kingdom and Google's exit, and you may be forced to FQ (Freegate) to complete this command. It may also be because the speed is too slow, the download time-out, you need to repeatedly try the above command.
In short, hard work is needed, and some unconventional means may be needed ...
The magical thing happened and you found a folder under your workspace.
Don't worry, you still need a little bit of steps.
3. Download the source code and templates used in the framework.
MVN Appfuse:full-source
This time if the system is running the environment JDK and the database MySQL (root password is empty) is ready, you can run to the Web Directory command MVN jetty:run deployment startup Project, login http://localhost:8080 access to your project!
4. Build the project file.
The command line current directory is switched to the MyProject directory. If you are using Eclipse, you can run: mvn eclipse:eclipse command. If you are using idea, run: mvn Idea:idea. Project files and related dependencies are generated.
5. Switch to the Oracle database.
Appfuse has prepared a variety of database options (profiles) for us. To view these profiles, you can type the following command:
MVN help:full-profiles
All display can be profiles.
MVN help:active-profiles
Displays the active profiles.
It was very simple, and we just had to execute the following command to switch to Oracle.
MVN Clean Install-p Oracle
Clears the files generated by the project and installs Oracle profile.
However, three errors were reported during execution, causing the execution to fail.
Issue 1: The ODBC jar package could not be found.
We found the Oracle-related warehouses in Maven's warehouse: c:\users\[localuser]\.m2\repository\com\oracle\ojdbc14\10.2.0.2.0. This warehouse is generated by Appfuse, but the following is missing a jar package. We need to download a 10.2.0.2.0 version of the Ojdbc14-.jar from the Oracle website and place it under this directory and rename it as: Ojdbc14-10.2.0.2.0.jar.
Some people feel that Oracle version is now 12, but also with 10 of the driver, a bit outdated. You can install your own Oracle library. The method is to download the oracle corresponding jar and execute the MAVEN command to install the JDBC dependency. I just installed the Oracle database 11.2G, using its driver, save the download.
MVN install:install-file-dfile=c:\app/[localuser]/product/11.2.0/dbhome_1/jdbc/lib/ojdbc6_g.jar-dgroupid= Com.oracle-dartifactid=ojdbc6-dversion=11.2.0-dpackaging=jar
If you do not have Oracle installed on this machine, or if the global database name is not XE, you may need to modify the default database connection options. Open file: C:\users\[localuser]\.m2\repository\org\appfuse\appfuse\3.5.0\appfuse-3.5.0.pom. Do the backup. Locate the Oracle-related profile and modify it to look like this:
< Profile> <ID>Oracle</ID> <Properties> <Dbunit.datatypefactoryname>Org.dbunit.ext.oracle.OracleDataTypeFactory</Dbunit.datatypefactoryname> <Dbunit.schema>MYPROJECT</Dbunit.schema> <!--Make sure to capitalize the schema name - <!--<dbunit.operation.type>CLEAN_INSERT</dbunit.operation.type> - <Hibernate.dialect>Org.hibernate.dialect.Oracle10gDialect</Hibernate.dialect> <Hibernate.export.schema.delimiter></Hibernate.export.schema.delimiter> <Jdbc.groupid>Com.oracle</Jdbc.groupid> <Jdbc.artifactid>Ojdbc6</Jdbc.artifactid> <jdbc.version>11.2.0</jdbc.version> <Jdbc.driverclassname>Oracle.jdbc.OracleDriver</Jdbc.driverclassname> <Jdbc.url><! [Cdata[Jdbc:oracle:thin: @localhost: 1521:orcl]]></Jdbc.url> <Jdbc.username>MyProject</Jdbc.username> <Jdbc.password>MyProject</Jdbc.password> <Jdbc.validationquery><! [Cdata[SELECT 1 + 1 from DUAL]]></Jdbc.validationquery> </Properties> </ Profile>
Where MyProject is the database I created specifically for the project. The global instance name for the native database is ORCL. JDBC has also been changed to 11.2. There are also some changes to follow that will be mentioned.
Issue 2: Database scripts cannot be executed. To the Myproject\core\target directory, locate the Schema.sql. Open the view, found everything is OK, you go to Sqlplus below execute this SQL file also no problem.
The reason for the file is that this SQL is not executed by sqlplus, but rather 2. There is hibernate execution! Hibernate cannot have a paragraph end that conforms to ";" when executing SQL statements. So the error! The workaround is to add a setting in Oracle profile in Appfuse-3.5.0.pom to set the paragraph break to null:
This problem is solved!
Issue 3: Unit tests do not pass. To report a strange mistake:
Tests Run:9, failures:0, Errors:1, skipped:0, time elapsed:2.167 sec <<< failure!
Testupdateuser (com.exam.dao.UserDaoTest) Time elapsed:0.088 sec <<< error!
Java.lang.Exception:Unexpected Exception, Expected<org.springframework.dao.dataintegrityviolationexception > But was<org.springframework.orm.hibernate4.hibernatesystemexception>
This issue has been submitted to Appfuse's mailing list, but there is no positive response, there is only one way to avoid it. Deep-seated causes require the ability of people to continue digging!
The workaround is to comment out the 68th line of the test code Userdaotest.java://user2.setroles (User.getroles ());
User2.setlastname (User.getlastname ()); User2.setpassword (User.getpassword ()); User2.setpasswordhint (User.getpasswordhint ()); // User2.setroles (User.getroles ()); User2.setusername (User.getusername ()); User2.setwebsite (User.getwebsite ());
Having modified these issues, Oracle profile successfully activates, tests through and generates jar packages, war packages.
In addition, the way I modify the Oracle Database Profile (APPFUSE-3.5.0.POM) is not advisable, the more scientific way is to modify the MyProject below the pom.xml.
<Properties>
... Other settings
<!--The following settings have been added for the linked Oracle database, and the default values for these settings point to the MySQL database - <Dbunit.datatypefactoryname>Org.dbunit.ext.oracle.OracleDataTypeFactory</Dbunit.datatypefactoryname> <Dbunit.schema>MYPROJECT</Dbunit.schema> <Hibernate.dialect>Org.hibernate.dialect.Oracle10gDialect</Hibernate.dialect> <Jdbc.groupid>Com.oracle</Jdbc.groupid> <Jdbc.artifactid>Ojdbc6</Jdbc.artifactid> <jdbc.version>11.2.0</jdbc.version> <Jdbc.driverclassname>Oracle.jdbc.OracleDriver</Jdbc.driverclassname> <Jdbc.url><! [Cdata[Jdbc:oracle:thin: @localhost: 1521:orcl]]></Jdbc.url> <Jdbc.username>MyProject</Jdbc.username> <Jdbc.password>MyProject</Jdbc.password> <Jdbc.validationquery><! [Cdata[SELECT 1 + 1 from DUAL]]></Jdbc.validationquery> </Properties>
AppFuse3.5 Docking Oracle Database