<link rel="stylesheet" href="https://js.how234.com/third-party/SyntaxHighlighter/shCoreDefault.css" type="text/css" /><script type="text/javascript" src="https://js.how234.com/third-party/SyntaxHighlighter/shCore.js"></script><script type="text/javascript"> SyntaxHighlighter.all(); </script>
java dev是什麼,讓我們一起了解一下:
dev是java後端使用mvn的開發環境,透過pom.xml配置,mvn區分dev,pro,local三種環境,local代表本地環境,dev代表開發環境,pro代表生產環境。
dev常用在項目開發中,dev,test和prod又是什麼意思?
開發環境(dev):開發環境是程序猿們專門用於開發的服務器,配置可以比較隨意,爲了開發調試方便,一般開啟全部錯誤報告。
測試環境(test):一般是克隆一份生產環境的配置,一個程序在測試環境工作不正常,那麼肯定不能把它發佈到生產機上。
生產環境(prod):是指正式提供對外服務的,一般會關掉錯誤報告,開啟錯誤日誌。
dev開發環境具體示例代碼如下:
<!--環境配置--> <profiles> <profile> <id>local</id> <properties> <!-- 環境標識,需要與配置檔案的名稱相對應 --> <activatedProperties>local</activatedProperties> </properties> </profile> <profile> <id>dev</id> <properties> <activatedProperties>dev</activatedProperties> </properties> <activation> <!-- 默認環境 --> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>pro</id> <properties> <activatedProperties>pro</activatedProperties> </properties> </profile> </profiles> <build> <resources> <resource> <!--配置檔案路徑 --> <directory>src/main/resources</directory> <!--這裏對應項目存放配置檔案的目錄--> <!--開啓filtering功能 --> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <!--創建一個自動可執行的jar或war檔案 --> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>