NutzCN Logo
问答 nutz生成的jar后如何启动它
发布于 2123天前 作者 qq_4945a577 1514 次浏览 复制 上一个帖子 下一个帖子
标签:

用maven生成好jar 后怎么把它跑起来,他自身携带tomcat,打成jar后如何启动呢?

25 回复

java -jar xxx.jar

控制台说报出“主清单属性”

没打包对吧,你怎么打包的?

用maven ,install打包的

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.nutz</groupId>
    <artifactId>demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <nutzboot.version>2.2-SNAPSHOT</nutzboot.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.nutz</groupId>
                <artifactId>nutzboot-parent</artifactId>
                <version>${nutzboot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.nutz</groupId>
            <artifactId>nutzboot-starter-swagger</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.nutz</groupId>
            <artifactId>nutzboot-starter-nutz-mvc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.nutz</groupId>
            <artifactId>nutzboot-starter-nutz-dao</artifactId>
        </dependency>
        <dependency>
            <groupId>org.nutz</groupId>
            <artifactId>nutzboot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
        </dependency>
        
        
        
        <dependency>
            <groupId>org.nutz</groupId>
            <artifactId>nutzboot-starter-tomcat</artifactId>
        </dependency>
        
        
        
        
        
        
        
        <dependency>
            <groupId>org.nutz</groupId>
            <artifactId>nutzboot-starter-shiro</artifactId>
        </dependency>
        
        
        
        
        
        
        
        
        
        
        
        
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.196</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>nutz</id>
            <url>http://jfrog.nutz.cn/artifactory/libs-release</url>
        </repository>
        <repository>
            <id>nutz-snapshots</id>
            <url>http://jfrog.nutz.cn/artifactory/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nutz-snapshots</id>
            <url>http://jfrog.nutz.cn/artifactory/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
            <releases>
                <enabled>false</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArgs>
                        <arg>-parameters</arg>
                    </compilerArgs>
                    <useIncrementalCompilation>false</useIncrementalCompilation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.3</version>
                <configuration>
                    <additionalparam>-Xdoclint:none</additionalparam>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.nutz.boot</groupId>
                <artifactId>nutzboot-maven-plugin</artifactId>
                <version>${nutzboot.version}</version>
            </plugin>
        </plugins>
    </build>
</project>

mvn clean package nutzboot:shade
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.100 s
[INFO] Finished at: 2018-06-05T18:06:40+08:00
[INFO] Final Memory: 6M/123M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\dell). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

得在当前项目的目录

[INFO] Scanning for projects...
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-parent/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-parent/2.2-SNAPSHOT/maven-metadata.xml (579 B at 1.5 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/boot/nutzboot-maven-plugin/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/boot/nutzboot-maven-plugin/2.2-SNAPSHOT/maven-metadata.xml (973 B at 15 kB/s)
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building demo 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-swagger/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-swagger/2.2-SNAPSHOT/maven-metadata.xml (1.2 kB at 18 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter/2.2-SNAPSHOT/maven-metadata.xml (580 B at 8.8 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-core/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-core/2.2-SNAPSHOT/maven-metadata.xml (1.2 kB at 19 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz/1.r.66-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz/1.r.66-SNAPSHOT/maven-metadata.xml (1.2 kB at 19 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-nutz-mvc/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-nutz-mvc/2.2-SNAPSHOT/maven-metadata.xml (1.2 kB at 19 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-nutz-dao/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-nutz-dao/2.2-SNAPSHOT/maven-metadata.xml (1.2 kB at 18 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-plugins-daocache/1.r.66-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-plugins-daocache/1.r.66-SNAPSHOT/maven-metadata.xml (980 B at 16 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzmore/1.r.66-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzmore/1.r.66-SNAPSHOT/maven-metadata.xml (576 B at 7.1 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-jdbc/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-jdbc/2.2-SNAPSHOT/maven-metadata.xml (1.2 kB at 17 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-tomcat/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-tomcat/2.2-SNAPSHOT/maven-metadata.xml (1.2 kB at 19 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-servlet3/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-servlet3/2.2-SNAPSHOT/maven-metadata.xml (964 B at 12 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-plugins-websocket/1.r.66-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-plugins-websocket/1.r.66-SNAPSHOT/maven-metadata.xml (981 B at 11 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-shiro/2.2-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutzboot-starter-shiro/2.2-SNAPSHOT/maven-metadata.xml (1.2 kB at 16 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-integration-shiro/1.r.66-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-integration-shiro/1.r.66-SNAPSHOT/maven-metadata.xml (981 B at 15 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-plugins-cache/1.r.66-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-plugins-cache/1.r.66-SNAPSHOT/maven-metadata.xml (977 B at 15 kB/s)
Downloading: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-integration-jedis/1.r.66-SNAPSHOT/maven-metadata.xml
Downloaded: http://jfrog.nutz.cn/artifactory/snapshots/org/nutz/nutz-integration-jedis/1.r.66-SNAPSHOT/maven-metadata.xml (981 B at 15 kB/s)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ demo ---
[INFO] Deleting D:\WorkSpace\IntelliJIDEAR_WorkSpace_No.1\demo\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ demo ---
[INFO] Compiling 2 source files to D:\WorkSpace\IntelliJIDEAR_WorkSpace_No.1\demo\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\WorkSpace\IntelliJIDEAR_WorkSpace_No.1\demo\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ demo ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ demo ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ demo ---
[INFO] Building jar: D:\WorkSpace\IntelliJIDEAR_WorkSpace_No.1\demo\target\demo-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- nutzboot-maven-plugin:2.2-SNAPSHOT:shade (default-cli) @ demo ---
[INFO] Including org.nutz:nutzboot-starter-swagger:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including io.swagger:swagger-servlet:jar:1.5.18 in the shaded jar.
[INFO] Including io.swagger:swagger-core:jar:1.5.18 in the shaded jar.
[INFO] Including org.apache.commons:commons-lang3:jar:3.2.1 in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-annotations:jar:2.9.3 in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-databind:jar:2.9.3 in the shaded jar.
[INFO] Including com.fasterxml.jackson.core:jackson-core:jar:2.9.3 in the shaded jar.
[INFO] Including com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.9.3 in the shaded jar.
[INFO] Including org.yaml:snakeyaml:jar:1.18 in the shaded jar.
[INFO] Including io.swagger:swagger-models:jar:1.5.18 in the shaded jar.
[INFO] Including io.swagger:swagger-annotations:jar:1.5.18 in the shaded jar.
[INFO] Including javax.validation:validation-api:jar:1.1.0.Final in the shaded jar.
[INFO] Including org.reflections:reflections:jar:0.9.11 in the shaded jar.
[INFO] Including org.javassist:javassist:jar:3.22.0-GA in the shaded jar.
[INFO] Including com.google.guava:guava:jar:20.0 in the shaded jar.
[INFO] Including org.nutz:nutzboot-core:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including javax.servlet:javax.servlet-api:jar:3.1.0 in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-nutz-mvc:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-nutz-dao:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz-plugins-daocache:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-jdbc:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including com.alibaba:druid:jar:1.1.10 in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-tomcat:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.31 in the shaded jar.
[INFO] Including org.apache.tomcat:tomcat-annotations-api:jar:8.5.31 in the shaded jar.
[INFO] Including org.nutz:nutzboot-servlet3:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz-plugins-websocket:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including javax.annotation:javax.annotation-api:jar:1.2 in the shaded jar.
[INFO] Including org.gandon.tomcat:juli-to-slf4j:jar:1.1.1 in the shaded jar.
[INFO] Including org.nutz:nutzboot-starter-shiro:jar:2.2-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz-integration-shiro:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.slf4j:jcl-over-slf4j:jar:1.7.25 in the shaded jar.
[INFO] Including org.apache.shiro:shiro-web:jar:1.3.2 in the shaded jar.
[INFO] Including org.apache.shiro:shiro-core:jar:1.3.2 in the shaded jar.
[INFO] Including commons-beanutils:commons-beanutils:jar:1.8.3 in the shaded jar.
[INFO] Including org.apache.shiro:shiro-ehcache:jar:1.3.2 in the shaded jar.
[INFO] Including net.sf.ehcache:ehcache:jar:2.10.4 in the shaded jar.
[INFO] Including org.nutz:nutz-plugins-cache:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.nutz:nutz-integration-jedis:jar:1.r.66-SNAPSHOT in the shaded jar.
[INFO] Including org.slf4j:slf4j-log4j12:jar:1.7.25 in the shaded jar.
[INFO] Including org.slf4j:slf4j-api:jar:1.7.25 in the shaded jar.
[INFO] Including log4j:log4j:jar:1.2.17 in the shaded jar.
[INFO] Including com.h2database:h2:jar:1.4.196 in the shaded jar.
[INFO] Remove META-INF/LICENSE.txt
[INFO] Remove META-INF/NOTICE.txt
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/NOTICE
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/NOTICE
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/NOTICE
[INFO] Remove META-INF/LICENSE.txt
[INFO] Remove META-INF/NOTICE
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/NOTICE
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/LICENSE.txt
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/NOTICE
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/NOTICE
[INFO] Remove META-INF/LICENSE.txt
[INFO] Remove META-INF/NOTICE.txt
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/NOTICE
[INFO] Remove META-INF/LICENSE
[INFO] Remove META-INF/NOTICE
[WARNING] tomcat-annotations-api-8.5.31.jar, javax.annotation-api-1.2.jar define 15 overlapping classes:
[WARNING]   - javax.annotation.ManagedBean
[WARNING]   - javax.annotation.PreDestroy
[WARNING]   - javax.annotation.Resource$AuthenticationType
[WARNING]   - javax.annotation.Generated
[WARNING]   - javax.annotation.security.DeclareRoles
[WARNING]   - javax.annotation.Priority
[WARNING]   - javax.annotation.Resource
[WARNING]   - javax.annotation.security.DenyAll
[WARNING]   - javax.annotation.security.RunAs
[WARNING]   - javax.annotation.sql.DataSourceDefinitions
[WARNING]   - 5 more...
[WARNING] javax.servlet-api-3.1.0.jar, tomcat-embed-core-8.5.31.jar define 79 overlapping classes:
[WARNING]   - javax.servlet.http.Cookie
[WARNING]   - javax.servlet.ServletContext
[WARNING]   - javax.servlet.Registration
[WARNING]   - javax.servlet.http.HttpSessionListener
[WARNING]   - javax.servlet.http.HttpSessionContext
[WARNING]   - javax.servlet.FilterChain
[WARNING]   - javax.servlet.http.WebConnection
[WARNING]   - javax.servlet.http.HttpServletRequestWrapper
[WARNING]   - javax.servlet.http.HttpSessionAttributeListener
[WARNING]   - javax.servlet.http.HttpSessionBindingListener
[WARNING]   - 69 more...
[WARNING] juli-to-slf4j-1.1.1.jar, slf4j-api-1.7.25.jar define 1 overlapping classes:
[WARNING]   - org.slf4j.LoggerFactory
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing D:\WorkSpace\IntelliJIDEAR_WorkSpace_No.1\demo\target\demo-1.0-SNAPSHOT.jar with D:\WorkSpace\IntelliJIDEAR_WorkSpace_No.1\demo\target\demo-1.0-SNAPSHOT-shaded.jar
[INFO] Dependency-reduced POM written at: D:\WorkSpace\IntelliJIDEAR_WorkSpace_No.1\demo\dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.586 s
[INFO] Finished at: 2018-06-05T18:09:47+08:00
[INFO] Final Memory: 45M/382M

除了juli-to-slf4j-1.1.1.jar这个警告之外,其他正常

我用clean 然后package 命令重新打包就跑起来了,因为我开始用的是install命令?

想起来了。。。那是我加的,让tomcat日志也要走slf4j

跑起来后如果想查看tomcat的运行日志怎么查看啊

clean package nutzboot:shade 全都需要

那是log4j.properties的事了

clean package nutzboot:shade后边的 nutzboot:shade是啥意思

这个项目是什么呀我该怎么做???

把这个打成jar放到maven 插件库然后到我的项目里pom里配置上再给我的项目打成jar吗

那是解释nutzboot:shade是什么

这个看不明白 '_'!!! ,没在书上看到过 ;_;更没没这么用过了

用中文讲的话,nutzboot:shade是干什么用的

需要 clean package nutzboot:shade 执行一次

添加回复
请先登陆
回到顶部