Jakarta Faces 4 (JSF) with Spring Security enabled Example
This example demonstrates the usage of the j-framework in creating a project with Spring Security enabled.
Prerequisites:
-
You should have JDK 17+ Installed. (Click Here).
-
You should create a Maven Project.
-
You should enable snapshot versions. (Click Here).
Project Content:
This section contains what you should add to your code structure for this example.
-
Maven Project with pom.xml that has the following contents:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jalalkiswani</groupId>
<artifactId>j-app-webstack</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>
<artifactId>j-framework-web-security-example</artifactId>
<packaging>war</packaging>
</project>
-
Configurations file located at
src/main/resources/config.properties
that has the following content:
hibernate.connection.url = jdbc:h2:file:./h2db.data
hibernate.connection.username=sa
hibernate.connection.password=sa
hibernate.hbm2ddl.auto=update
db-entities-packages=com.jk.webstack.security
jk.security.enabled=true
-
Main java class located at
src/main/java/com/app/App.java
which contains the following:
package com.app;
import com.jk.web.embedded.JKWebApplication;
public class App {
public static void main(String[] args) {
JKWebApplication.run();
}
}
Alternatively, you can clone or download the tutorial repository then import the project into your IDE. |
How to run Project:
-
Set up the project with the content shown above.
-
Inside your IDE, go to the
src/main/java/com/app/App.java
class.
-
Next, run it as a Java Application.
-
Your program will start running and will open your browser to show you the result of the run. Alternatively, after running the code, you can open any browser to localhost on port 8080, and it will show you the run output as well.