File tree Expand file tree Collapse file tree 5 files changed +5
-41
lines changed
UserManagement/src/main/java/com/hms/mangement/UserManagement Expand file tree Collapse file tree 5 files changed +5
-41
lines changed Original file line number Diff line number Diff line change 66import javax .sql .DataSource ;
77import java .beans .PropertyVetoException ;
88
9-
10-
119@ Configuration
1210@ PropertySource ("classpath:application.properties" )
1311public class Configurations {
@@ -26,9 +24,6 @@ public class Configurations {
2624
2725 @ Bean
2826 public DataSource datasource () throws PropertyVetoException {
29- /*ApplicationContext context = new ClassPathXmlApplicationContext("been.xml");
30- DataSource dataSource = (DataSource) context.getBean("dataSource");
31- return dataSource;*/
3227 System .out .println ("hello" +dbPassword );
3328 return DataSourceBuilder
3429 .create ()
@@ -41,12 +36,14 @@ public DataSource datasource() throws PropertyVetoException {
4136
4237 @ Bean
4338 public JdbcTemplate jdbcTemplate (){
39+
4440 try {
4541 return new JdbcTemplate (datasource ());
4642 } catch (PropertyVetoException e ) {
4743 e .printStackTrace ();
4844 return null ;
4945 }
46+
5047 }
5148 @ Bean
5249 public UserDAOClass userDAO (){
Original file line number Diff line number Diff line change 11package com .hms .mangement .UserManagement ;
2-
32import com .google .gson .Gson ;
43import org .springframework .context .ApplicationContext ;
54import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
6- import org .springframework .context .support .ClassPathXmlApplicationContext ;
75import org .springframework .web .bind .annotation .*;
8-
96import java .util .List ;
107
118@ RestController
@@ -14,7 +11,6 @@ public class Controller {
1411 private ApplicationContext context ;
1512 private UserDAO userJDBCTemplate ;
1613
17-
1814 public Controller () {
1915 this .context = new AnnotationConfigApplicationContext (Configurations .class );
2016 this .userJDBCTemplate = context .getBean (UserDAO .class );
@@ -23,7 +19,6 @@ public Controller() {
2319
2420 @ GetMapping (value = "/Users" )
2521 public String viewUsers () {
26- System .out .println ("hello get" );
2722
2823 List <User > users = userJDBCTemplate .viewAllUsers ();
2924 if (users != null ) {
Original file line number Diff line number Diff line change 55
66public interface UserDAO {
77
8-
9- //public void setDataSource(DataSource ds);
10-
11- /**
12- * This is the method to be used to create
13- * a record in the User table.
14- */
158 public void create (User user );
169
1710 public String updatePassword (int UserId , String oldPassword , String newPassword );
1811
1912 public String deleteUser (int id );
2013
21- /**
22- * This is the method to be used to list down
23- * all the records from the User table.
24- */
2514 public List <User > viewAllUsers ();
2615}
Original file line number Diff line number Diff line change 77public class UserDAOClass implements UserDAO {
88 @ Autowired
99 private JdbcTemplate jdbcTemplate ;
10- // private DataSource dataSource;
1110
12- /*
13-
14- @Override
15- public void setDataSource(DataSource ds) {
16- this.dataSource = ds;
17-
18- }
19- */
2011 public JdbcTemplate getJdbcTemplate () {
12+
2113 return jdbcTemplate ;
2214 }
2315
24-
25-
2616 public void setJdbcTemplate (JdbcTemplate jdbcTemplate ) {
17+
2718 this .jdbcTemplate = jdbcTemplate ;
2819 }
2920
@@ -34,8 +25,6 @@ public void create(User user) {
3425
3526 }
3627
37-
38-
3928 @ Override
4029 public String deleteUser (int id ) {
4130 User user = isIdExist (id );
Original file line number Diff line number Diff line change 11package com .hms .mangement .UserManagement ;
22
3- import org .springframework .beans .factory .annotation .Value ;
43import org .springframework .boot .SpringApplication ;
5- import org .springframework .boot .autoconfigure .EnableAutoConfiguration ;
64import org .springframework .boot .autoconfigure .SpringBootApplication ;
7- import org .springframework .context .ApplicationContext ;
8- import org .springframework .context .support .ClassPathXmlApplicationContext ;
95
106@ SpringBootApplication
117public class UserManagementApplication {
12-
13-
14- public static void main (String [] args ) {
8+ public static void main (String [] args ) {
159 SpringApplication .run (UserManagementApplication .class , args );
1610
1711 }
You can’t perform that action at this time.
0 commit comments