Maven & Springboot

This commit is contained in:
2022-06-14 11:45:09 +05:30
parent a6509debfd
commit fcb5ad1ec7
13 changed files with 203 additions and 1 deletions

View File

@@ -25,4 +25,5 @@ if the problem still persist then create a issue or use Google/Stack Overlflow f
|2 | [PrivateConSingleton.java](https://github.com/psavarmattas/Java-Projects/blob/master/IndustrialTrainingProjects/PrivateConSingleton.java) | Program to implement private constructor using the Singleton method. |
|3 | [EmployeeModelClass.java](https://github.com/psavarmattas/Java-Projects/blob/master/IndustrialTrainingProjects/EmployeeModelClass.java) | Program to create Model Class, Getters, Setters and display the data. |
|4 | [TwoDimensionalArraySum.java](https://github.com/psavarmattas/Java-Projects/blob/master/IndustrialTrainingProjects/TwoDimensionalArraySum.java) | Program to sum 2 two dimensional arrays forming a matrix. |
|5 | [CompoundInterestCalculator.java](https://github.com/psavarmattas/Java-Projects/blob/master/IndustrialTrainingProjects/CompoundInterestCalculator.java) | Program to calculate compound interest for the provided principle amount & time by following certain criteria. |
|5 | [CompoundInterestCalculator.java](https://github.com/psavarmattas/Java-Projects/blob/master/IndustrialTrainingProjects/CompoundInterestCalculator.java) | Program to calculate compound interest for the provided principle amount & time by following certain criteria. |
|6 | [testAppMaven](https://github.com/psavarmattas/Java-Projects/blob/master/IndustrialTrainingProjects/testAppMaven) | Program to understand maven configs with Spring Boot Framework. |

View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="testAppMaven" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="testAppMaven" options="-parameters" />
</option>
</component>
</project>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
</component>
</project>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>testAppMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.20</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,14 @@
package demo;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) {
// Getting application context and configuring class path of the xml file
AbstractApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
student st = context.getBean(student.class); // Spring get bean method
st.studyJava(); // Calling the method studyJava from student class
System.out.println(student.getName()); // Using get name method to print the value of variable name
}
}

View File

@@ -0,0 +1,27 @@
package demo;
import org.springframework.stereotype.Component;
@Component //Annotation in Spring Boot
public class student {
private static String name; // Name variable to use constructor, getter & setters
public static String getName() { // Get Method to get the value of variable name
return name;
}
public void setName(String name) { // Set Method to set the value of variable name
student.name = name;
}
// Constructor method with old config in spring.xml
// public student(String name) {
// student.name = name;
// System.out.println(name);
// }
public void studyJava(){ // Random method created to check the working of this class
System.out.println("Student is studying java");
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Old Beans Config-->
<!--<beans xmlns="http://www.springframework.org/schema/beans"-->
<!-- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"-->
<!-- xsi:schemaLocation="-->
<!-- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">-->
<!-- <bean id="stu" class="demo.student">-->
<!-- <property name="name" value="Puranjay"> </property>-->
<!-- <constructor-arg value="I am a constructor" type="String"> </constructor-arg>-->
<!-- </bean>-->
<!--</beans>-->
<!--New Beans Config-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="demo"/>
</beans>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--Old Beans Config-->
<!--<beans xmlns="http://www.springframework.org/schema/beans"-->
<!-- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"-->
<!-- xsi:schemaLocation="-->
<!-- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">-->
<!-- <bean id="stu" class="demo.student">-->
<!-- <property name="name" value="Puranjay"> </property>-->
<!-- <constructor-arg value="I am a constructor" type="String"> </constructor-arg>-->
<!-- </bean>-->
<!--</beans>-->
<!--New Beans Config-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="demo"/>
</beans>