Giter VIP home page Giter VIP logo

javajava's Introduction

有自己的经验,也有从老师傅那里偷来的。 编程就跟练武一样,只要练好内功,框架再怎么更新都只是花架子而已。N年前的规范拿到现在依然是最棒的,不得不感叹前辈的高明。

MY BEST PRACTISE

代码模板生成器

https://www.jhipster.tech/

API 文档

https://docsify.js.org/#/

IDEA Plugins

alibaba-p3c sonarlint 代码风格:google-code-style.xml

IDEA + JRebel

JRebel支持热部署,使用方法:

https://zeroturnaround.com/software/jrebel/quickstart/intellij/?run=ide#!/reload

1. [Activation](https://my.jrebel.com/account/how-to-activate)
2. Press the jrebel-ide-icon Run with JRebel 
3. 
  a. Open View > Tool Windows > JRebel. The JRebel Panel window opens.
  b. Enable JRebel for the desired modules by selecting the  column checkboxes.
4.
  a. Restart your Java application using jrebel-ide-icon Run with JRebel (or from the command line).
  b. Change something in the application code.
  c. Use Build > Build Project command to compile classes and update your application.

激活要先完成第一步的流程。 因为是第一次用JRebel,所以先JRebel启动,然后第3步完成勾选,再重新启动JRebel。第二次就直接使用JRebel启动项目,无须勾选。

使用内置Jetty容器启动web项目。

pom.xml

<packaging>war</packaging>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>9.4.9.v20180320</version>
</plugin>

add configuration > maven 在command line 里:clean:clean jetty:run

map2json

pom.xml

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.9.5</version>
</dependency>

spring-mvc.xml

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
    <property name="messageConverters">
        <list>
            <ref bean="mappingJacksonHttpMessageConverter"/>
        </list>
    </property>
</bean>

<bean id="mappingJacksonHttpMessageConverter"
      class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
    <property name="supportedMediaTypes">
        <list>
            <bean class="org.springframework.http.MediaType">
                <constructor-arg index="0" value="text"/>
                <constructor-arg index="1" value="plain"/>
                <constructor-arg index="2" value="UTF-8"/>
            </bean>
            <bean class="org.springframework.http.MediaType">
                <constructor-arg index="0" value="*"/>
                <constructor-arg index="1" value="*"/>
                <constructor-arg index="2" value="UTF-8"/>
            </bean>
            <bean class="org.springframework.http.MediaType">
                <constructor-arg index="0" value="text"/>
                <constructor-arg index="1" value="*"/>
                <constructor-arg index="2" value="UTF-8"/>
            </bean>
            <bean class="org.springframework.http.MediaType">
                <constructor-arg index="0" value="application"/>
                <constructor-arg index="1" value="json"/>
                <constructor-arg index="2" value="UTF-8"/>
            </bean>
        </list>
    </property>
</bean>

这里仅支持UTF-8编码,即请求头Accept的编码,如:Accept:application/json;charset=utf-8,其它的可能会乱码或没有对应的converter。

bean-based configuration Spring Framwork + Hibernate

javajava's People

Contributors

carl-zk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.