Pynguins

Spring Notes

Spring Boot Initializer:
http://start.spring.io/

Run a application:
mvnw spring-boot:run

Make a RestController:
 @RestController

Make a route:
 @RequestMapping(value="/test", method=RequestMethod.GET)

Moved controllers etc into different package, add:
 @ComponentScan("com.pynguins.controllers")

Send data to controller:
     public ModelAndView index() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("index");
        mav.addObject("message", "hello world from controller");
        return mav;
    }
Then in template:
 <p>${message}</p>

File Upload:
https://github.com/dustinschultz/just-gif-it

Deploy Webapp:
https://stormpath.com/blog/tutorial-spring-boot-war-files
https://www.youtube.com/watch?v=kDZ5KkVQDxE

JSP Tags:
http://stackoverflow.com/questions/1296235/jsp-tricks-to-make-templating-easier

Useful Application Properties
 spring.session.store-type=none
spring.datasource.url = jdbc:mysql://localhost:3306/pyracms
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=
spring.mvc.view.prefix: ../
spring.mvc.view.suffix: .jsp
server.port=6543
spring.thymeleaf.cache=false
security.basic.enabled=false

Spring Template Path Bug:
https://github.com/spring-projects/spring-boot/issues/34
http://stackoverflow.com/questions/29782915/spring-boot-jsp-404
http://stackoverflow.com/questions/26031254/how-to-use-spring4-restcontroller-to-return-a-jsp-page
Turns out files *have* to go in myproject\src\main\webapp\WEB-INF

http://stackoverflow.com/questions/22084623/how-do-i-move-my-src-main-webapp-web-inf-views-folder-out-of-src-main-webapp
Might need this in pom.xml
 		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.tomcat.embed</groupId>
			<artifactId>tomcat-embed-jasper</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>jstl</artifactId>
                </dependency>

Official JSP Example: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp

If you want hibernate, you can use something like this:
 		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>5.2.6.Final</version>
		</dependency>

Comments | Gallery