Skip to content

Instantly share code, notes, and snippets.

@yusufsoysal
Created March 18, 2017 16:35
Show Gist options
  • Save yusufsoysal/dcb6748e0fbcbece7311aa1b48371028 to your computer and use it in GitHub Desktop.
Save yusufsoysal/dcb6748e0fbcbece7311aa1b48371028 to your computer and use it in GitHub Desktop.
IntelliJ IDEA Java Class Template
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
#set($isClassService = $NAME.endsWith("Service"))
#set($isClassController = $NAME.endsWith("Controller"))
#if (${isClassController})
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping(value = "CHANGE_ME")
#elseif (${isClassService})
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
#end
public class ${NAME} {
#if (${NAME.endsWith("Service")})
#set($lastIndex = $NAME.lastIndexOf("Service"))
#set($daoClass = $NAME.substring(0,$lastIndex) + "Dao")
@Autowired
private ${daoClass} dao;
#elseif (${NAME.endsWith("Controller")})
#set($lastIndex = $NAME.lastIndexOf("Controller"))
#set($serviceClass = $NAME.substring(0,$lastIndex) + "Service")
@Autowired
private ${serviceClass} service;
#end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment