Skip to content

Latest commit

 

History

History
245 lines (168 loc) · 11 KB

File metadata and controls

245 lines (168 loc) · 11 KB

Запуск: mvn spring-boot:run

Коннект к базе (только 1 коннект возможен):

  • профиль prod

    • приложение не работает jdbc:h2:file:~/db/javaops
    • приложение работает: jdbc:h2:tcp://localhost:9092/~/db/javaops
  • профиль dev

    • jdbc:h2:tcp://localhost:9092/mem:javaops

Spring Boot generate/run

  1. Profiles.

  2. Add H2. WebServer/TcpServer

  3. Model User/Role. Repository UserRepository.

  4. Security/ UserDetailService/ LoggedUser

  5. Add Rest

  6. Add mail

  7. Switch to war: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file

  8. Run with active profile: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-set-active-spring-profiles ~/.bashrc export SPRING_PROFILES_ACTIVE=prod . ~/.bashrc

http://stackoverflow.com/questions/285015/linux-prevent-a-background-process-from-being-stopped-after-closing-ssh-client

alias run='cd ~/javaops; nohup mvn spring-boot:run &'

  1. Modify Tomcat config Tomcat location: http://stackoverflow.com/questions/12280372/where-can-i-find-the-tomcat-7-installation-folder-on-linux-ami-in-elastic-beanst /usr/share/tomcat8 http://stackoverflow.com/questions/32327522/spring-boot-yml-and-standalone-tomcat-8-server

  2. Set in props https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-set-active-spring-profiles

AWS

Setting Up with Amazon EC2

http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-advanced.html http://mtdevuk.com/2015/02/10/how-to-deploy-a-spring-boot-application-to-amazon-aws-using-elastic-beanstalk/

Static resources

http://www.baeldung.com/spring-mvc-static-resources

nginx/unix

Run at 80 port: http://stackoverflow.com/questions/33703965/spring-boot-running-app-on-port-80

sudo su yum install -y nginx yum install mc

cat /etc/init.d/nginx Ctrl+D (exit)

config: /etc/nginx/nginx.conf

config: /etc/sysconfig/nginx

cat /etc/sysconfig/nginx cat /etc/nginx/nginx.conf

su/sudo

https://www.tollmanz.com/nginx-location-match-homepage/ http://stackoverflow.com/questions/11954255/nginx-how-to-set-index-html-as-root-file

sudo service nginx reload/stop/start

https://www.digitalocean.com/community/tutorials/how-to-optimize-nginx-configuration

Open 80 port: http://stackoverflow.com/questions/5004159/opening-port-80-ec2-amazon-web-services

https://en.wikipedia.org/wiki/Chmod

http://stackoverflow.com/questions/6795350/nginx-403-forbidden-for-all-files namei -om /home/ec2-user/javaops/static/index.html

How do I run a Unix process in the background?

External properties

http://www.javabeat.net/spring-boot-external-configurations/

H2

http://stackoverflow.com/questions/221379/hibernate-hbm2ddl-auto-update-in-production http://stackoverflow.com/questions/18077327/hibernate-hbm2ddl-auto-possible-values-and-what-they-do-any-official-explanat http://stackoverflow.com/questions/20089470/hibernate-is-not-auto-creating-a-table-that-does-not-exist-in-the-db

Preconditions in java

Comparison Preconditions in Java

Configuration props

Add AppConfig http://blog.codeleak.pl/2014/09/using-configurationproperties-in-spring.html http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#configuration-metadata-annotation-processor

@PropertySource

http://www.jayway.com/2014/02/16/spring-propertysource/ http://www.mkyong.com/spring/spring-propertysources-example/ http://blog.jamesdbloom.com/UsingPropertySourceAndEnvironment.html http://stackoverflow.com/questions/13728000/value-not-resolved-when-using-propertysource-annotation-how-to-configure-prop

additional-spring-configuration-metadata.json

OAuth2

https://github.com/spring-cloud-samples/authserver

Execution and Scheduling

CompletionService over an ExecutorService

Omitting many details:

ExecutorService = incoming queue + worker threads CompletionService = incoming queue + worker threads + output queue

http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#scheduling http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#scheduling-enable-annotation-support

10 советов по использованию ExecutorService

http://docs.spring.io/spring-javaconfig/docs/1.0.0.M4/reference/html/ch04s02.html

JSON

@JsonAutoDetect(fieldVisibility= ANY, getterVisibility= NONE, isGetterVisibility= NONE, setterVisibility= NONE)

Globally: https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring#with-spring-boot

OK http://stackoverflow.com/questions/28324352/how-to-customise-the-jackson-json-mapper-implicitly-used-by-spring-boot

http://docs.spring.io/spring-boot/docs/current/reference/html/howto-spring-mvc.html#howto-customize-the-jackson-objectmapper

spring-projects/spring-boot#2116

https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring#customizing-the-jackson-objectmapper

http://stackoverflow.com/questions/29807879/jackson2objectmapperbuilder-enable-field-visibility-any#35326628

org/springframework/spring-webmvc/4.2.4.RELEASE/spring-webmvc-4.2.4.RELEASE-sources.jar!/org/springframework/web/servlet/mvc/method/annotation/ AbstractMessageConverterMethodProcessor.java:213

Test

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html http://stackoverflow.com/questions/13866533/how-to-create-a-completed-future-in-java

Templates, Thymeleaf

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-spring-mvc-template-engines JSP limitation: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/

http://blog.codeleak.pl/2014/04/how-to-spring-boot-and-thymeleaf-with-maven.html Alt+R: http://stackoverflow.com/questions/27919315/spring-boot-hot-deployment-for-templates-and-resources-under-intellij

text mode: http://forum.thymeleaf.org/Thymeleaf-and-plain-text-e-mail-or-other-non-HTML-XML-templates-td4026349.html

Unescaped Text http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#unescaped-text

Inlining http://www.thymeleaf.org/doc/tutorials/2.1/usingthymeleaf.html#inlining

Using multiple template resolvers

http://blog.kaczmarzyk.net/2015/01/04/loading-view-templates-from-database-with-thymeleaf/ http://stackoverflow.com/questions/26609226/using-multiple-template-resolvers-with-spring-3-2-and-thymeleaf-2-1-3-for-emails

Bootstrap

http://itchief.ru/lessons/bootstrap-3/110-bootstrap-3-callouts

Serving Static Web Content with Spring Boot

https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot

Exception handling

Resource:

Cache

Guava https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-caching.html#boot-features-caching-provider-guava

Inner call: http://stackoverflow.com/questions/12115996/spring-cache-cacheable-method-ignored-when-called-from-within-the-same-class https://spring.io/blog/2012/05/23/transactions-caching-and-aop-understanding-proxy-usage-in-spring

VK

https://habrahabr.ru/post/265563/ https://api.vk.com/method/users.get?domain=grigory.kislin&v=5.37&access_token=.. https://geektimes.ru/post/125155/

Cascade

http://stackoverflow.com/questions/5787551/should-i-let-jpa-or-the-database-cascade-deletions http://stackoverflow.com/questions/2856460/hibernate-doesnt-generate-cascade https://dzone.com/articles/spring-caching-abstraction-and

Logging

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-logging.html#boot-features-logging-file-output

Error handling

http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-error-handling

org.springframework.web.servlet.DispatcherServlet.getHandler #1115