――For various reasons, I am studying Spring Boot. ――I don't remember Java itself, Servlets, JSPs, etc. too long ago. So it will be a beginner start. ――I was able to make a simple SPA in about 16 hours in total, while fitting it securely in each step. ――There is no special design.
# | OS/software/Library | version |
---|---|---|
1 | Mac OS X | EI Capitan |
2 | Java | 1.8.0_111 |
3 | Tomcat | 8.0.43 |
4 | MySQL | 5.6.38 |
# | OS/software/Library | version |
---|---|---|
1 | Eclipse | 4.5 Mars |
2 | Gradle | 4.4.1 |
# | OS/software/Library | version |
---|---|---|
1 | Spring Boot | 1.5.9 |
2 | JPA(Java Persistence API) | |
3 | Thymeleaf |
brew update && brew upgrade && brew cleanup
Java
brew cask install java
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
Tomcat
brew install tomcat
Gradle
brew install gradle
https://www.eclipse.org/downloads/packages/release/Mars/2
Place Eclipse.app under / Applications.
** Japanese localization plug-in ** http://mergedoc.osdn.jp/#pleiades.html
JStyle http://mergedoc.osdn.jp/#jstyle.html
Place the jp.sourceforge.mergedoc.pleiades directory of the unzipped plugin under /Applications/Eclipse.app/Contents/Eclipse/plugins/.
Open /Applications/Eclipse.app/Contents/Eclipse/eclipse.ini and add the writing.
-Xverify:none
-javaagent:/Applications/Eclipse.app/Contents/Eclipse/plugins/jp.sourceforge.mergedoc.pleiades/pleiades.jar
JStyle
Place the unzipped plugin jar under /Applications/Eclipse.app/Contents/Eclipse/plugins/.
After starting, open the environment settings at the top left of the screen.
--From "Java> Compiler", change the Java version to 1.8. --Add Java SE 8 from "Java> Installed JRE". --Adjust the "General> JStyle" settings. --Set "General> Web Browser". --If proxy settings are required, set "General> Network Connection".
After startup, open "Server> Runtime Environment" from the environment settings at the top left of the screen.
/usr/local/Cellar/[email protected]/8.0.43/libexec
-Edit /projectname/src/main/resources/application.properties.
//Tomcat startup port
server.port=18080
//Database connection settings
spring.datasource.url=jdbc:mysql://localhost:3306/{Database name}
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
――This time, I created the following functions.
# | Function name |
---|---|
1 | List user information |
2 | Partial match search for user name and group name |
3 | Display user information |
4 | Username update |
--Users have attributes such as groups to form a join relationship.
CREATE DATABASE {Database name} DEFAULT CHARACTER SET utf8;
CREATE TABLE `groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`group_id` int(11) NOT NULL,
`name` varchar(20) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
INSERT INTO `groups` VALUES (1,'admin'),(2,'sales');
INSERT INTO `users` VALUES (1,1,'Tanaka'),(2,2,'Takahashi'),(3,2,'Suzuki');
--I learned from Domain Driven (DDD) and constructed the class, but please understand that it may contain some code that is not so good. --The actual source code.
https://github.com/neriai/spring-boot-sandbox
Select the project, right-click and click Run> Spring Boot Application.
――It was more likely to fit in JPA, Thymeleaf or other libraries than in Java or Spring Boot. --Gradle Easy to use. --The area around Entity fits. --It is recommended to set it as a shortcut for running or stopping the application in Eclipse.
Recommended Posts