@Test public void getProjectName() { String projectName = PropertyHolder.getProjectName(); Assert.equals(projectName, "demo", ErrorCodeDef.SYSTEM_ERROR_10001); }
public static String getProjectName() { String name = getProperty("project.name"); if (StringUtils.isEmpty(name)) { String realPath = StringUtils.replaceEach( PropertyHolder.class.getClassLoader().getResource(GlobalConstants.BLANK).getPath(), new String[] { "/target/classes/", "/WEB-INF/classes/" }, new String[] { GlobalConstants.BLANK, GlobalConstants.BLANK }); name = realPath.substring(realPath.lastIndexOf(GlobalConstants.PATH_SPLITOR)); } return name; }
PropertyHolder { public static String getProjectName() { String name = getProperty("project.name"); if (StringUtils.isEmpty(name)) { String realPath = StringUtils.replaceEach( PropertyHolder.class.getClassLoader().getResource(GlobalConstants.BLANK).getPath(), new String[] { "/target/classes/", "/WEB-INF/classes/" }, new String[] { GlobalConstants.BLANK, GlobalConstants.BLANK }); name = realPath.substring(realPath.lastIndexOf(GlobalConstants.PATH_SPLITOR)); } return name; } }
PropertyHolder { public static String getProjectName() { String name = getProperty("project.name"); if (StringUtils.isEmpty(name)) { String realPath = StringUtils.replaceEach( PropertyHolder.class.getClassLoader().getResource(GlobalConstants.BLANK).getPath(), new String[] { "/target/classes/", "/WEB-INF/classes/" }, new String[] { GlobalConstants.BLANK, GlobalConstants.BLANK }); name = realPath.substring(realPath.lastIndexOf(GlobalConstants.PATH_SPLITOR)); } return name; }  }
PropertyHolder { public static String getProjectName() { String name = getProperty("project.name"); if (StringUtils.isEmpty(name)) { String realPath = StringUtils.replaceEach( PropertyHolder.class.getClassLoader().getResource(GlobalConstants.BLANK).getPath(), new String[] { "/target/classes/", "/WEB-INF/classes/" }, new String[] { GlobalConstants.BLANK, GlobalConstants.BLANK }); name = realPath.substring(realPath.lastIndexOf(GlobalConstants.PATH_SPLITOR)); } return name; }  static Map<String, String> getProperties(); static Boolean getBooleanProperty(final String name); static Boolean getBooleanProperty(final String name, final Boolean defaultValue); static Integer getIntProperty(final String name); static Integer getIntProperty(final String name, final Integer defaultValue); static Long getLongProperty(final String name); static Long getLongProperty(final String name, final Long defaultValue); static String getProperty(final String name); static String getProperty(final String name, final String defaultValue); static void setProperty(final String name, final String value); static String getErrorMessage(final int code, final Object... params); static String getProjectName(); static String getVersion(); }
PropertyHolder { public static String getProjectName() { String name = getProperty("project.name"); if (StringUtils.isEmpty(name)) { String realPath = StringUtils.replaceEach( PropertyHolder.class.getClassLoader().getResource(GlobalConstants.BLANK).getPath(), new String[] { "/target/classes/", "/WEB-INF/classes/" }, new String[] { GlobalConstants.BLANK, GlobalConstants.BLANK }); name = realPath.substring(realPath.lastIndexOf(GlobalConstants.PATH_SPLITOR)); } return name; }  static Map<String, String> getProperties(); static Boolean getBooleanProperty(final String name); static Boolean getBooleanProperty(final String name, final Boolean defaultValue); static Integer getIntProperty(final String name); static Integer getIntProperty(final String name, final Integer defaultValue); static Long getLongProperty(final String name); static Long getLongProperty(final String name, final Long defaultValue); static String getProperty(final String name); static String getProperty(final String name, final String defaultValue); static void setProperty(final String name, final String value); static String getErrorMessage(final int code, final Object... params); static String getProjectName(); static String getVersion();  }