Code review comment: Yes you need to seed the stack with the original root folder `/`.

Code under review:
private void collectKnownPaths(Path resource, StaticResourceInfo staticResourceInfo) {

        try {
            Files.walkFileTree(resource, new SimpleFileVisitor<Path>() {

                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                        throws IOException {
                    Path relativePathOfDir = resource.relativize(dir);
                    Path dirName = dir.getFileName();
                    Path parentOfDir = dir.getParent().getFileName();

                    if (!staticResourceInfo.resourceMap.containsKey(relativePathOfDir)) {
                        StaticResourceInfo.StaticFile newStaticFile = new StaticResourceInfo.StaticFile(dirName.toString(),
                                attrs.isDirectory(), null);
                        staticResourceInfo.resourceMap.put(relativePathOfDir, newStaticFile);

                        
                        if (staticResourceInfo.resourceMap.containsKey(parentOfDir)) {
                            StaticResourceInfo.StaticFile valueOfParentKey = staticResourceInfo.resourceMap.get(parentOfDir);
                            List<StaticResourceInfo.StaticFile> retrieveChildListFromParent = valueOfParentKey.children;
                            retrieveChildListFromParent.add(newStaticFile);
                            staticResourceInfo.resourceMap.put(parentOfDir, new StaticResourceInfo.StaticFile(
                                    parentOfDir.toString(), true, retrieveChildListFromParent));
                        } else {
                            List<StaticResourceInfo.StaticFile> childList = new ArrayList<>();
                            childList.add(newStaticFile);
                            StaticResourceInfo.StaticFile parentStaticFile = new StaticResourceInfo.StaticFile(
                                    parentOfDir.toString(), true, childList);
                            staticResourceInfo.resourceMap.put(parentOfDir, parentStaticFile);
                        }
                    }
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attributes)
                        throws IOException {
                    String fileName = file.getFileName().toString();
                    String completeParentPath = file.getParent().toString();
                    String relativeFileName = resource.relativize(file).toString();
                    Path parentDirectory = file.getParent().getFileName();

                    StaticResourceInfo.StaticFile childStaticFile = new StaticResourceInfo.StaticFile(fileName,
                            attributes.isDirectory(), null);

                    
                    if (staticResourceInfo.resourceMap.containsKey(parentDirectory)) {
                        StaticResourceInfo.StaticFile valueOfParentKey = staticResourceInfo.resourceMap.get(parentDirectory);
                        List<StaticResourceInfo.StaticFile> retrieveChildList = valueOfParentKey.children;
                        retrieveChildList.add(childStaticFile);
                        StaticResourceInfo.StaticFile updatedParent = new StaticResourceInfo.StaticFile(
                                parentDirectory.toString(), true, retrieveChildList);
                        staticResourceInfo.resourceMap.put(parentDirectory, updatedParent);
                    } else {
                        List<StaticResourceInfo.StaticFile> childList = new ArrayList<>();
                        childList.add(childStaticFile);
                        StaticResourceInfo.StaticFile parentStaticFile = new StaticResourceInfo.StaticFile(
                                parentDirectory.toString(), true, childList);
                        staticResourceInfo.resourceMap.put(parentDirectory, parentStaticFile);
                    }

                    return FileVisitResult.CONTINUE;
                }

                
                @Override
                public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                    return FileVisitResult.CONTINUE;
                }
            });
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

Line commented on: List<StaticResourceInfo.StaticFile> childList = new ArrayList<>();

Revised code:
private void collectKnownPaths(Path resource, StaticResourceInfo staticResourceInfo) {

        try {
            Files.walkFileTree(resource, new SimpleFileVisitor<Path>() {
                final Stack<StaticResourceInfo.StaticFile> currentFolder = new Stack<>();

                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {

                    Path relativeFile = resource.relativize(dir);
                    String relativeFileString = "/" + relativeFile.toString();
                    Path dirName = dir.getFileName();
                    StaticResourceInfo.StaticFile getStaticFile = staticResourceInfo.resourceMap.get(relativeFileString);
                    if (getStaticFile == null) {
                        getStaticFile = new StaticResourceInfo.StaticFile(dirName.toString(), true);
                        staticResourceInfo.resourceMap.put(relativeFileString, getStaticFile);

                        
                        if (!currentFolder.isEmpty()) {
                            currentFolder.peek().children.add(getStaticFile);
                        }
                    }
                    currentFolder.push(getStaticFile);
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    String fileName = file.getFileName().toString();
                    StaticResourceInfo.StaticFile newStaticFile = new StaticResourceInfo.StaticFile(fileName, false);

                    List<StaticResourceInfo.StaticFile> childrenList = currentFolder.peek().children;
                    childrenList.add(newStaticFile);

                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                    Collections.sort(currentFolder.peek().children);
                    currentFolder.pop();
                    return FileVisitResult.CONTINUE;
                }
            });
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }